Spring MVC multipartfile uploads files when the file is small (10k) and cannot be uploaded successfully.

Source: Internet
Author: User

<!--SPRINGMVC You need to configure the Multipartresolver processor when uploading files -      <BeanID= "Multipartresolver"class= "Org.springframework.web.multipart.commons.CommonsMultipartResolver">          < Propertyname= "Defaultencoding"value= "UTF-8"/>          <!--Specifies that the total size of the uploaded file cannot exceed 200KB. Note the limitations of the Maxuploadsize attribute are not for individual files, but for the sum of the capacity of all files -          < Propertyname= "Maxuploadsize"value= "1024000"/>        < Propertyname= "Fileitemfactory.sizethreshold"value= "0"></ Property>      </Bean>

View this type of source code

There is a description document

* <p>provides "Maxuploadsize", "Maxinmemorysize" and "defaultencoding" settings as
* Bean Properties (inherited from {@link commonsfileuploadsupport}). See corresponding
* Servletfileupload/diskfileitemfactory Properties ("Sizemax", "Sizethreshold",
* "headerEncoding") for details in terms of defaults and accepted values.

Enter Commonsfileuploadsupport

diskfileitemfactory fileitemfactory;private final FileUpload fileupload;private Boolean Uploadtempdirspecified = false;

Enter

Diskfileitemfactory  
See
/**      * The threshold above which uploads is stored on disk.      */    Private int sizethreshold = default_size_threshold;//default_size_threshold=10240 is 10k

Set this parameter.

Spring MVC multipartfile uploads files when the file is small (10k) and cannot be uploaded successfully.

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.