ajaxSubmit提交中文乱码或者不走success方法

一、js请求

function upload() { if($("#uploadExcel").val()==""){ return; }//2016-05-23 12071093 modify $("#uploadButton").removeAttr("onclick"); $("#uploadButton").html("正在上传中。。。"); var url=url; var options = { type : 'post', url : url, clearForm : false, resetForm : false, success : function(data) { if(datahttps://www.it610.com/article/==""){ alert("导入成功"); }else{ alert("导入失败:"+data); $("#uploadButton").attr("onclick","upload(); "); } }, error : function() { alert("系统异常,文件大于2M,请分多个文件上传"); } }; $("#excelForm").ajaxSubmit(options); }

二、java代码
@RequestMapping(valuehttps://www.it610.com/article/= "" ) @ResponseBody public String uploadScopeOfCollectAndSend(HttpServletRequest request, HttpServletResponse response) { String returnMsg = ""; try { // 获取上传文件 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile multipartFile = multipartRequest.getFile("uploadExcel"); // 执行保存 returnMsg ="数据异常" } catch (Exception e) { returnMsg = "系统异常"; LOGGER.error("导入揽派范围失败:" + MsgHandleUtil.getExceptionString(e)); } return returnMsg; }

三、异常信息
这样请求的时候,返回到前端中文乱码,后来在请求上面加入
@RequestMapping(valuehttps://www.it610.com/article/= "" produces={"application/json; ","text/html; charset=UTF-8; "})

这样请求变成了,不走success方法,直接报错了;
后来发现请求的有点换问题,换成了下面的请求头,可以正常返回。
@RequestMapping(valuehttps://www.it610.com/article/= "" ,produces = "text/text; charset=UTF-8")


【ajaxSubmit提交中文乱码或者不走success方法】

    推荐阅读