Struts2 file upload resets form if maxsize exceeds
posted 4 years ago
I am uploading a file using the struts2 file uploder. In struts.xml I set struts.multipart.maxSize to 1 MB. If the file limit exceeds after import, my form data is reset and all user inputs are appearing as blank (I have some text fields along with the file upload control). In the logs I am getting the error 'The request was rejected because its size exceeds the configured maximum' which is expected. I am printing the action errors in JSP and this message is printed in the JSP , which is again as expected.
But why my form data is getting reset?
Another point is if I set maxSize in the fileUpload interceptor it works fine, I am getting errors message with form data kept as it is. The issue is only with the struts2 struts.multipart.maxSize setting in the struts.xml. According to my observation struts.multipart.maxSize takes precedence than the interceptor maxsize setting, so I need to set a upload limit in struts.multipart.maxSize.
And other xml basesd struts validations are working fine for me, where I get validation errors printed on page, but form data is not lost after validation run.
Anybody faced this issue .. Can somebody help to resolve this? Any suggestions appreciated.....