It's easy to upload a spring file with ready-made tools. It is possible to make some mistakes when you are not very familiar with it.
Recently ran into
Org.apache.catalina.connector.RequestFacade cannot is cast to Org.springframework.web.multipart.MultipartHttpServletRequest
This exception, very many people say enctype= "multipart/form-data" This property is not set, but I have set. Say let's add in config file
<bean id= "Multipartresolver" class= "Org.springframework.web.multipart.commons.CommonsMultipartResolver" > <property name= "maxuploadsize" value= "104857600"/><property name= "maxinmemorysize" value= "4096"/></ Bean>
of this statement. I have already configured, also said to join the dependency package
<dependency><groupid>commons-fileupload</groupid><artifactid>commons-fileupload</ Artifactid><version>1.3.1</version></dependency><dependency><groupid> Commons-io</groupid><artifactid>commons-io</artifactid><version>2.4</version> </dependency>
My pom file also exists, the last thought is not to upload files related? Because the server side receives the client's upload file, I see an article wrote
Create a generic multipart parser commonsmultipartresolver multipartresolver = new Commonsmultipartresolver (Request.getsession () . Getservletcontext ()); Infer if the request has a file upload, that is, multipart request if (Multipartresolver.ismultipart (Request)) { //Convert to multi-part requests
There was no inference that there was a multipart request. Instead of casting directly, the conversion error is reported. Since I didn't upload the file, I just simulated some other form data. So no multipart requests cause an error.
Spring MVC file Upload, request object Conversion exception