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