Spring mvc 返回Json乱码

@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;
         
    }

 

posted @ 2017-06-08 14:29  miMnM  阅读(155)  评论(0编辑  收藏  举报