@RequestMapping(value="learn") @ResponseBody public String learnBlog(){ List<TBlog> queryAll = blogService.queryAll(); String blogList = JSON.toJSONString(queryAll); return blogList; }
通过Response Body返回的Json数据格式为ISo-8859-1
通过在设置RequestMapping的produces即可解决乱码问题
@RequestMapping(value="learn", produces = "text/html;charset=UTF-8") @ResponseBody public String learnBlog(){ List<TBlog> queryAll = blogService.queryAll(); String blogList = JSON.toJSONString(queryAll); return blogList; }