Fastjson: @ResponseBody 返回response异常

Created on 10 Oct 2017  ·  3Comments  ·  Source: alibaba/fastjson

js代码:
success: function (response) {
alert(response);}

controller代码:
@RequestMapping("/checklogin")
@ResponseBody
public String checkLogin() {
return "error";
}

js接受的字符是"error",而不是error,多了双引号
如图
image

Most helpful comment

阅读下json规范 http://www.json.org/json-zh.html
单字符串是由双引号包围的任意数量Unicode字符的集合

All 3 comments

阅读下json规范 http://www.json.org/json-zh.html
单字符串是由双引号包围的任意数量Unicode字符的集合

感谢解答~

你可以debug看一下js的XHR对象,
返回里不仅有responseText,还有responseJSON
后面一个应该不会返回双引号

Was this page helpful?
0 / 5 - 0 ratings