解决 java的ajax提交返回值中文乱码问题

2026-02-14 03:33:18

1、 确定的是(经过多次测试的结果)只有当返回值是 String时才会出现中文乱码,而当返回值是Map<String, Object>或者是其它类型时,并没有中文乱码的出现.

2、在@RequestMapping的并发配置中加products="text/html;charset=UTF-8"

可以解决

3、或在配置文件中的mvc:annotation-driven中添加

<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> 

1、<mvc:annotation-driven >  里添加

<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/> 

猜你喜欢