前台页面json格式数据中文显示问号

在练习SSM整合案例,后台进行更新和删除时,直接返回了json字符串给前台页面

 但是前台页面会显示问号

 此时已经在web.xml中配置了编码过滤器,但还是会出现乱码

 最后发现通过以下方式可以解决问题:

在springmvc配置文件中的注解驱动 <mvc:annotation-driven>中加入以下配置

<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
原文地址:https://www.cnblogs.com/coderLeo/p/12951683.html