Struts2 Upload and download

Source: Internet
Author: User

One

1, file upload is a frequently used knowledge of Web applications. The principle is that by setting the Enctype= "Multipart/form-data" property for the form element, the data submitted by the form is submitted in binary encoding, and in the servlet receiving the request, the contents of the uploaded file can be obtained with the binary stream. To achieve file upload.
2, Struts2 file upload:
STRUTS2 does not provide its own request resolver, which means that STRUTS2 does not handle the Multipart/form-data request, it needs to invoke the other request parser to parse the form field in the HTTP request. But Struts2 in the original upload parser based on the further encapsulation, further simplifying the file upload.
STRUTS2 uses the Jakarta common-fileupload framework to upload files by default, so To add two jar files to a web app: Commons-fileupload-1.2.jar and Commons-io-1.3.1.jar. It has been further encapsulated on the original upload frame, simplifying the implementation of the file upload code, and canceling the programming differences on different upload frames.
If you want to change to another file upload frame, you can modify the value of the Struts.multipart.parser constant to Cos/pell, the default value is Jakata. and add the class library of the corresponding upload component in Classpath.
Ii. Steps and their realization
See also: http://mib168.iteye.com/blog/930706 or: http://perfectplan.iteye.com/blog/1561963

Struts2 Upload and download

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.