This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
Struts2 file upload resets form if maxsize exceeds
posted 5 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.....