笔记:解决springMVC返回中文乱码问题

xiaoxiao2021-02-28  89

方法一

@RequestMapping(value="/testCharset",produces="text/html;charset=UTF-8")

在@RequestMapping中加入produces=”text/html;charset=UTF-8”;

方法二

<mvc:annotation-driven> <!-- 设置返回信息字符集, 默认为iso --> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes" value="text/plain;charset=UTF-8" /> </bean> </mvc:message-converters> </mvc:annotation-driven>

在springMVC配置文件中加入上边代码

转载请注明原文地址: https://www.6miu.com/read-84777.html

最新回复(0)