Struts2 file Upload Size limit issue

Source: Internet
Author: User

Struts2 default File Upload size is 2M, if you want to modify the default size, the workaround is as follows:

<struts>      <constant name= "struts.multipart.maxSize" value= "20971520"/> <!--setting allows maximum  20MB ( 1024*1024*20)--      <package name= "Build" extends= "Struts-default" >    <action name= "FileUpload" class= "com.home.UploadAction" method= "Upload" >   <result name= "Success" >/success.jsp</result>   <result name= "input" >/error.jsp</result>   <!--<param name= "Allowedtypes" ></param > Allow file Types--   <interceptor-ref name= "FileUpload" >   <param name= "MaximumSize" >5242880</ param>   </interceptor-ref>   <interceptor-ref name= "Defaultstack"/> <!--default Interceptor--    </action>      </package></struts>


Struts.multipart.maxSize and FileUpload interceptors have different maximumsize attribute divisions

1. struts.multipart.maxSize controls the maximum size of files uploaded by the entire project. Above this value, background error

The request was rejected because its size (51224434) exceeds the configured maximum (20971520)

2. The MaximumSize attribute of the FileUpload interceptor must be less than the value of struts.multipart.maxSize.

Struts.multipart.maxSize default 2M, when MaximumSize is greater than 2M, you must set the value of struts.multipart.maxSize greater than maximumsize.

3. When uploading files between MaxSize and MaximumSize, the system prompts

the file is to large to being Uploaded:file "Apache-tomcat-7.0.47.zip" "Upload_94d9d06c_a45f_b91e4c915c02_00000002.tmp" 8782342

4, when the upload file is less than MaximumSize, upload success.

Summary: The uploaded file size should be < MaximumSize < maxSize



Struts2 file Upload Size limit issue

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.