@RequestMapping(value = "getJSON", method = RequestMethod.GET,produces={"text/html;charset=UTF-8;","application/json;"} )
@ResponseBody
public String getJson(HttpServletRequest request,HttpServletResponse response){
response.setCharacterEncoding("UTF-8");
return "说到底";
}前台.ajax({
type: "GET",
url: "getJSON.do",
success: function(data){
console.log(data);
}
网上说加produces=“ { }”
加了还是乱码。Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
还得看你的web容器是什么编码啊... 踩着踩着也就过去了.