The example in this article describes the method of uploading images and files using Struts2+jquery.form.js. Share it with everyone for your reference, the details are as follows:
jquery.form.js is an official jQuery plug-in that supports asynchronous file upload. Official website: http://plugins.jquery.com/form/
Combined with Struts2 to easily upload files in three steps
Generally, a page may have more than one Form form, so submitting a form on one side will affect another form. For this reason, the image upload form can be uploaded using the non-refresh submission method, which is an asynchronous upload. At this time, jquery .from.js comes in handy.
1. HTML
Import this jS to the page and write the upload form
1 2 3 4 5 6 |
|
2. JS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
3. Struts2Action
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
4. Configure Struts2.xml
1 2 3 |
|
Okay, I’ve finished writing from the page to the backend. Then you can upload it. complete!
Readers who are interested in more jQuery related content can check out the special topics on this site: "JQuery switching effects and techniques summary", "jQuery drag effects and techniques summary", "JQuery extension skills summary", "jQuery common classic special effects summary", "jQuery animation and special effects usage summary", "jquery selector usage Summary " and "Summary of jQuery common plug-ins and usage "
I hope this article will be helpful to everyone in jQuery programming.