Spring MVC file Upload, request object Conversion exception

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.