below to introduce the file upload non-Ajax submitted to the background data operation method, the specific details are shown below;
<form name= "Configform" id= "Configform" "method=" Post "action=" "> ...
</form>
Get form data based on ID and then send AJAX request, get background return data, process data, perfect.
But if you need to upload files,
<tr>
<td class= "FontSize" > Please select File:</td>
<td><input type= "class=" Easyui-filebox "Id=" FileImport "name=" file "value=" "style=" width:300px; " ></td>
</tr>
This file data is not in the background, the form data This file is also null, you need
<form name= "Configform" id= "Configform" method= "POST" action= "" enctype= "Multipart/form-data" >
Add this enctype= "mutipart/form-data" background can be
@RequestMapping ("/saveappversion")
@ResponseBody public
modelmap saveappversion (String action, Tbdappversion tbdappversion,
@RequestParam (value = "file") Multipartfile file) {...
}
Receive.
However, the form submission request data must be required, Ajax is still not good (specific reasons can be Baidu. )
<form name= "Configform" id= "Configform" "method=" Post "action="/admin/systemconfig/saveappversion.do "enctype=" Multipart/form-data "> ...
</form>
Easyui inside the JS submit submitted
Handler:function () {
$ ("#configForm"). Submit ();
So the question is, how do I get back the background data after the submission?
<form name= "Configform" id= "Configform" method= "post" action= "/admin/systemconfig/saveappversion.do
" Enctype= "Multipart/form-data" target= "Myiframe" > .... </form>
<iframe name= "Myiframe" id= "If_json" style= "Display:none" >
</iframe>
Add a target to the form, which means that the data submitted for the successful return is written in the IFRAME named Myiframe, which refreshes the IFRAME and then gets the data.
Although Baidu is not a good bird, but some things can still be found, such as the following to obtain the method of IFRAME data!
Handler:function () {
$ ("#configForm"). Submit ();
$ ("#if_json"). Load (function () {//Get content in iframe
var body = $ (window.frames[' myiframe '].document.body);
var data = eval (' (' + body[0].textcontent + ') ');
if (data.resultcode && data.resultcode!= 0) {
...
.. }else{.....
}}
);
The above is a small series to introduce the relevant file upload non-Ajax submitted to the background data, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!