SpringMvc---使用@ResponseBody注解中文乱码问题

在SpringMvc的配置文件中写上,规定响应报文的文本格式和字符编码格式

  • 注意必须标注@RequestBody注解,否则不会调用此消息转换器
<!--开启mvc的注解驱动-->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html; charset=UTF-8"/>
<property name="defaultCharset" value="UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>

 

posted @ 2021-11-24 22:12  优质水  阅读(59)  评论(0)    收藏  举报