Methods to solve the Chinese garbled return value of java's ajax submission: 1. Add code [products=text/html;charset=UTF-8] to the concurrent configuration of RequestMapping; 2. In the file [mvc: annotation-driven] Add code.
[Related article recommendations: ajax video tutorial]
Solution to java's ajax submission return value in Chinese Methods for garbled characters:
1. It is determined (as a result of many tests) that Chinese garbled characters will only appear when the return value is String, and when the return value is Map<String , Object>
or other types, no Chinese garbled characters appear.
2. Add
products="text/html;charset=UTF-8"
to the concurrent configuration of @RequestMapping to solve the problem
3, or add
<bean class= "org.springframework.http.converter.StringHttpMessageConvertr"> <property name="supportedMediaTypes"> <list> <span style="white-space:pre"></span> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> <value>*/*;charset=UTF-8</value> </list>
to mvc:annotation-driven in the configuration file. Related learning recommendations: java basic tutorial
The above is the detailed content of What should I do if the return value of Java's ajax submission is Chinese garbled?. For more information, please follow other related articles on the PHP Chinese website!