我用的架构是springMVC
后台代码:
@SuppressWarnings("static-access")
@RequestMapping("/uploadFile")
public String fileUpload(@RequestParam("files")MultipartFile[] files,HttpServletResponse response) throws IOException{
JsonResult<String> jsonResult = new JsonResult<String>();
JSONObject json = (JSONObject) JSONObject.toJSON(jsonResult);
String msg = json.toJSONString(); //解决IE上传问题
response.setContentType("text/html;charset=utf-8");
response.getWriter().write(msg);
return null;
}
注 : 不要使用 @ResponseBody 注解
前台代码:
$.ajaxFileUpload({
url: cur_url+"/attachmentUploadController/uploadFile",
secureuri: false,
fileElementId: 'files',
dataType: 'text',
data:mydata,
type:"post",
success: function(data ,textStatus) {}
扫描二维码关注公众号,回复:
5457796 查看本文章