Home  >  Article  >  Java  >  What should I do if the return value of Java's ajax submission is Chinese garbled?

What should I do if the return value of Java's ajax submission is Chinese garbled?

coldplay.xixi
coldplay.xixiOriginal
2020-08-21 10:41:112105browse

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.

What should I do if the return value of Java's ajax submission is Chinese garbled?

[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 Map06aeaed652f099bdd7b965333c229a74 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn