因为Spring MVC中返回json要使用@ResponseBody注解,而在Spring源码中这个注解的默认编码是“iso-8859-1”,所以传中文的话会乱码。解决办法是,直接使用response的writer来返回json数据。
@RequestMapping(path="/receive",method=RequestMethod.POST)@ResponseBodypublic void receive() throws IOException{PrintWriter out = response.getWriter();out.write(JsonData); //直接用Writer写}