controller返回中文字符串,网页中文字符显示 “???”
程序员文章站
2022-04-03 08:52:52
...
@RequestMapping(value = "/test", method = RequestMethod.GET, produces = "text/plain;charset=UTF-8")
@ResponseBody
public String getSinfo(HttpServletRequest request,
HttpServletResponse response) {
response.setCharacterEncoding("utf8");
response.setContentType("text/plain; charset=utf-8");
String testJson = "{" + "'message': '信息'," + "'success': 'true',"
+ "'result': {" + " 'id': 'ddd'," + " 'xxxx': {"
+ " 'fssj': '2018-05-02 10:10:00'," + " 'fsdd': 'XX地方',"
+ "'jb': '2级'" + "}" + "}" + "}";
return testJson;
}
上一篇: 解决中文乱码方式的一种方法
下一篇: 读磁盘文件的中文内容打印输出乱码