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