...
Library | URL | Struts 2.0.x | Struts 2.1.x |
---|---|---|---|
Commons-FileUpload | http://commons.apache.org/fileupload/![]() | 1.1.1 | 1.2.1 |
Commons-IO | http://commons.apache.org/io/![]() | 1.0 | 1.3.2 |
If you are using Maven then you can add these libraries as dependencies in your project's pom.xml.
...
As mentioned in the previous section one technique for uploading multiple files would be to simply have multiple form input elements of type file all with different names. This would require a number of setter methods that was equal to 3 times the number of files being uploaded. Another option is to use Arrays or java.util.Lists. The following examples are taken from the Showcase example application that is part sample applications you can download at http://struts.apache.org/download.cgi. For the Action mapping details see
struts-fileupload.xml
in the sample application download.
...
The struts.multipart.parser
used by the fileUpload interceptor to handle HTTP POST requests, encoded using the MIME-type multipart/form-data, can be changed out. Currently there are two choices, jakarta and pell. The jakarta parser is a standard part of the Struts 2 framework needing only its required libraries added to a project. The pell parser uses Jason Pell's multipart parser instead of the Commons-FileUpload library. The pell parser is a Struts 2 plugin, for more details see: http://cwiki.apache.org/S2PLUGINS/pell-multipart-plugin.html. There was a third alternative, cos, but it was removed due to licensing incompatibilities.