SPRINGMVC Learning-Uploading a file decomposition Commonsmultipartresolver class

Source: Internet
Author: User

The main function of the Spring component Commonsmultipartresolver class is to configure some properties of the file upload, or to control the size of the uploaded file.

In the Springmvc-servlet.xml configuration file:

<BeanID= "Multipartresolver"class= "Org.springframework.web.multipart.commons.CommonsMultipartResolver">< Propertyname= "Defaultencoding">
     <!--encoding --<value>UTF-8</value></ Property>< Propertyname= "Maxuploadsize">
     <!--The maximum value of the uploaded file, such as within 20M limit: 20*1024*1024=52428800 --<value>52428800</value></ Property>
   <!--cache size -< Propertyname= "Maxinmemorysize"><value>4096</value></ Property></Bean>

The ID of the generic bean is only used as a unique identifier, but here you have to make sure that the ID is multipartresolver, and the others are Localeresolver, themeresolver, and so on.

Why fixed ID?

The reason is that the ID of these beans is fixed in the core class dispatcherservlet of SPRINGMVC. The code is as follows:

 Public class extends Frameworkservlet {    publicstaticfinal String multipart_resolver_bean_name = "Multipartresolver";      Public Static Final String locale_resolver_bean_name = "Localeresolver";      Public Static Final String theme_resolver_bean_name = "Themeresolver";

Later, if the configuration is normal but does not work, you can go to Dispatcherservlet to see if the ID is fixed.

SPRINGMVC Learning-Uploading a file decomposition Commonsmultipartresolver class

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.