springmvc返回json乱码

注解方式:@RequestMapping(value="/路径",method = RequestMethod.GET,produces= MediaType.APPLICATION_JSON_VALUE+";charset=utf-8")

springmvc配置:

<!-- 处理请求返回json字符串的乱码问题 -->
<MVC:annotation-driven>
<MVC:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</MVC:message-converters>
</MVC:annotation-driven>

<!--定义扫描的包-->
<context:component-scan base-package="com.whz.controller01"></context:component-scan>
posted @ 2022-03-04 10:30  小魏同学呀  阅读(136)  评论(0)    收藏  举报