The dependency package for the commons-fileupload-1.3.1.jar toolkit is commons-io-2.2.jar (fileuploaddepends on commons Io, so make sure you have the version mentioned on thedependenciespage in your classpath before continuing .)
Commons-fileupload-1.3.1.jar
The Wiki on the official website explains: commons-fileuploadmakes it easy to add robust, high-performance, file upload capability to yourservlets and Web applications. That is, the files are supported by servlets native. How to use it in struts2 can only be learned through the official website docs.
Demo provided on the official website
Http://commons.apache.org/proper/commons-fileupload/streaming.html
I found struts2 demo http://www.zuidaima.com/share/1833981853305856.htm here
After learning the struts2 demo, I solved the problem.
The following is my code:
After successful:
It is worth noting that after a file is uploaded, the file extension must be determined before it is uploaded. The file upload directory is configured in struts. XML, and the file information is transmitted from the JSP file to the action.
Upload images using the commons-fileupload-1.3.1.jar Toolkit