ajax请求springmvc返回json乱码
$jq.ajax({
url: '${/request/@context_path}/hls/hlssignattachmentcontroller'+'?frameworkAgreementId='+frameworkAgreementId+'&userId='+userId,
method: 'get',
success: function (args) {
Leaf.showMessage('提示', args.message);
Leaf.Masker.unmask(Ext.getBody(), '${l:HLS.EXECUTING}');
return;
},
java controller
@RequestMapping(value = {"/hls/hlssignattachmentcontroller"}, produces = "application/json;charset=UTF-8")//produces不生效
@ResponseBody
public ResponseData sendInfo(HttpServletResponse response, Integer frameworkAgreementId, Integer userId) {
ResponseData responseData = new ResponseData();
response.setContentType("text/html;charset=utf-8");//添加后生效
try {
iSignAttachmentService.sendInfo(frameworkAgreementId, userId);
responseData.setSuccess(true);
responseData.setMessage(HfaConstant.SUCCESS_MSG);
return responseData;
} catch (ParamsException e) {
e.printStackTrace();
responseData.setSuccess(false);
responseData.setMessage(e.getMsg());
return responseData;
}
catch (ServiceException e) {
e.printStackTrace();
responseData.setSuccess(false);
responseData.setMessage(e.getMessage());
return responseData;
}
catch (Exception e) {
e.printStackTrace();
responseData.setSuccess(false);
responseData.setMessage(e.getMessage());
return responseData;
}
}
原因:返回对象为json形式
参考https://www.cnblogs.com/roy-blog/p/7048401.html