Workaround:
1. Configure produces in @requestmapping annotations on the controller processing method
@RequestMapping (value= "/getrolelist.html", produces={"Application/json;charset=utf-8"}) @ResponseBody PublicObject getrolelist () {HashMap<String,List<Role>> resultmap=NewHashmap<string, list<role>>(); List<Role> rolelist=roleservice.getrolelist (); Resultmap.put ("Rolelist", rolelist); for(Role role:rolelist) {logger.info ("Role ID" +role.getid () +role.getrolename ()); } returnJsonarray.tojsonstring (rolelist);//convert Resultmap to JSON format to return}
2, in the SPRINGMVC configuration Stringhttpmessageconverter
<Mvc:annotation-driven> <mvc:message-converters> <Beanclass= "Org.springframework.http.converter.StringHttpMessageConverter"> < Propertyname= "Supportedmediatypes"> <List> <value>Application/json;charset=utf-8</value> </List> </ Property> </Bean> </mvc:message-converters> </Mvc:annotation-driven>
3, 1, 2 have tried or garbled, modified @requestmapping value attribute suffix name, tried several suffix names, in addition to. html, can return to Chinese normally
// Modify the value suffix name @RequestMapping (value= "/getrolelist.do", produces= {"Application/json;charset=utf-8"}) @ Responsebody// Modify the value suffix name @RequestMapping (value= "/getrolelist", produces={" Application/json;charset=utf-8 "}) @ResponseBody
Estimated to be related to the return of @responsebody, first remember to understand and then add
JSON Data passing Chinese garbled problem