easyui ajax表单上传 springMVC
1.页面
<form id="form1" method="post" enctype="multipart/form-data">
<input id="files" name="files" type="file" class="textfield" />
</form>
2.js
$.messager.progress();
$('#form1').form('submit', {
url:'uploadFile.do',
onSubmit: function(){
var isValid = $(this).form('validate');
if (!isValid){
$.messager.progress('close');
}
return isValid;
},
success:function(datas){
$.messager.progress('close');
var data = eval('(' + datas + ')');
if (data.success){
alert(data.message)
}
}
});
3.action
@RequestMapping("/uploadFile.do")
public String uploadLicense(MultipartHttpServletRequest mRequest,HttpServletRequest request, HttpServletResponse response) throws Exception {
try{
Map<String, MultipartFile> fileMap = mRequest.getFileMap();
MultipartFile mFile = fileMap.get("files");
String fileName = mFile.getOriginalFilename();
}catch(Exception e){
logger.error(e.getMessage(), e);
}
return null;
}
相关推荐
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo