Solve the size of the uploaded file in struts2.0

Source: Internet
Author: User
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

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.