How to solve the problem of question mark garbled characters when json is transmitted to the front-end using ajax? ajaxjson
Springmvc I use transmits a json file to the front-end at the controller layer. It is okay to display the text in the background. The Chinese text is displayed normally and then to the front-end.
The Chinese character becomes a question mark.
Later found, because the controller returned json with @ ResponseBody, and spring source code in the implementation class @ ResponseBody found that the default encoding is iso-8859-1, and the project is encoded as UTF-8, therefore, garbled characters may occur when the Chinese characters are passed.
Here I use annotations to solve the problem:
@ RequestMapping (value = "/echarts. do", produces = "application/json; charset = UTF-8 ")
This method is applicable to the new spring version. The version of this project:
<Spring. version> 4.1.4.RELEASE </spring. version>
The above is a small series of solutions to the problem of question mark garbled characters when using ajax to transmit json to the front-end Chinese. I hope it will help you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!