Home > Java > javaTutorial > 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
Release: 2020-08-21 10:41:11
Original
2209 people have browsed it

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 Map<String , Object> or other types, no Chinese garbled characters appear.

2. Add

products="text/html;charset=UTF-8"
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template