@RequestMapping (value= "/askquestion", method = Requestmethod.get, produces = {"Application/json,charset=utf-8"}) @ Responsebodypublic string Askquestion (@RequestParam (value= "content", Required=true) string content,
Returns a string.
The Springmvc @ResponseBody can convert the returned object directly to JSON. However, when the return value is a string, the Chinese language will appear garbled.
is not the same as the converter that returns the object and returns a String. The converter that returns string is Iso-8859-1. So there is garbled
。。
Solution to the online search.
1. When a string is returned, the string result is transferred
return new String ("Hello". GetBytes (), "iso-8859-1");
2. Add @requestmapping Annotations, configure the value of produces
produces = {"Application/json;charset=utf-8"}
3.StringHttpMessageConverter rewrite
Chinese characters garbled when using SPRINGMVC request to return a string