easyui ajax表单上传 springMVC

阅读更多

 

1.页面

files" type="file" class="textfield" />

 

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 fileMap = mRequest.getFileMap();
   MultipartFile mFile = fileMap.get("files");
   
   String fileName = mFile.getOriginalFilename();

 

 

}catch(Exception e){
   logger.error(e.getMessage(), e);
  }
  return null;
 }

 

你可能感兴趣的:(easyui ajax表单上传 springMVC)