首页 > 代码库 > SpringMVC中返回JSON时乱码的解决方案

SpringMVC中返回JSON时乱码的解决方案

springMVC中返回JSON会出现乱码,解决如下:

produces = "text/html;charset=UTF-8"
@ResponseBody
    @RequestMapping(value = { "searchUsers.htm" },method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    public String searchUsers(@ModelAttribute User user,Integer currentPage) throws JsonGenerationException, JsonMappingException, IOException {
        PageData<User> pageData =http://www.mamicode.com/ userService.serchUsers(user,currentPage);
        return JSONUtil.getEscapeJSONString(pageData);
    }

 

SpringMVC中返回JSON时乱码的解决方案