Solve the size of the uploaded file in struts2.0-struts2.0
The problem is as follows:
To upload a file, you need to limit the size of the file to be uploaded. This can be solved by configuring the interceptor of action. You only need to set the value of maximumsize, here I set 1048576 (1 m ).
If I upload a MB file, an error is returned. You can configure struts in the global international resource file. messages. error. file. too. large. there is no problem.
However, when I upload a file of 5 MB, I will report
# The request was rejected because its size (xxxxxx) exceeds
Configured maximum
(Xxxxxx) error. in addition, all the original parameters on the upload page are lost. for example, the ID value uploaded to the upload page when I modify a record. (Why is the data?
Lost)
This is because the default size of the file to be uploaded by struts2.0 is 2 MB. If the size of the file to be uploaded exceeds this value, an error is returned. You can modify the default file to be uploaded in struts. xml.
Part Size: <constant name = "struts. multipart. maxsize" value = "5242880"
/>, I set it to 5 MB, which allows uploading 5 MB files.
Struts. multipart. maxsize =
5242880
If the size of the File Uploaded by the user exceeds the size of the iterceptor in the action, but is smaller than the size set in the Struts. xml file, everything is normal.
The file size exceeds the size set in the Struts. xml file, and the problem occurs. Although the upload page can be normally returned, the data is lost...
Http://pepa.javaeye.com/blog/254901