<form id="fileForm" enctype="multipart/form-data" method="post">
<input type="file" id="file" name="file" style="width: 200px">
</form>
jquery代码:
$('#fileForm').form('submit',{
url:"········",success:function(data){
// change the JSON string to javascript object
var msg = eval('(' + data + ')');
if (msg.success) {
alert(1);
}else{
alert(2);
}
}
});
java代码:
@RequestMapping(params = "addFile")
@ResponseBody
public SuccessMsg addFile(MultipartFile numFile){
SuccessMsg msg = new SuccessMsg();
return msg;
}