springMVC return json data garbled ask

In springMVC controller in return json data garbled problem, because there is no code, only need a simple comment on it

Was added @RequestMapping () in produces = "text / html; charset = UTF-8" attribute to, the following:

    @RequestMapping(value="/respost",method=RequestMethod.GET,produces="text/html;charset=UTF-8")
    @ResponseBody
    public String postList(@RequestParam("topicId") String topicId){
        List<Post> posts=new ArrayList<Post>();
        System.out.println("topicId-----"+topicId);
        posts=postService.findPostList(topicId);
        JSONArray postJson=JSONArray.fromObject(posts);
        return postJson.toString();
    }    

 

Guess you like

Origin www.cnblogs.com/yysbolg/p/11101988.html