Implementation of file upload and download function with struts 2 in Java

Let's talk about the principle of uploading and downloading struts 2 files:

Struts 2 is uploaded through the common fileUpload file.

Commons fileUpload saves the HTTP data to a temporary folder, and then struts uses the fileUpload interceptor to bind the file to the action instance. Thus, we can operate the files uploaded by the browser in the form of local files.

Specific implementation:

1、 Create index JSP page

Create result JSP page

Of course, don't forget to add the struts 2 tag reference <% @ taglib prefix = "s" URI = "/ struts tags"% >

2、 Create updown JS file, in index Reference in JSP

3、 Create updownloadaction java

Note: the get and set methods of the property have been omitted.

4、 Finally, the configuration file

1、web. XML configuration

2、struts. XML configuration

A simple struts 2 multi file upload and single file download is realized.

The above is the whole content of this article. I hope it will be helpful to your study.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>