解决Spring MVC 参数乱码问题

1:RequestBody返回中文乱码解决方案

<!-- 启用 Annotation 驱动  -->
	<mvc:annotation-driven>
	    <mvc:message-converters register-defaults="true">
	    	<!-- 解决RequestBody返回中文乱码 -->
		    <bean class="org.springframework.http.converter.StringHttpMessageConverter">
		       <property name="supportedMediaTypes">     
                <list>
                    <value>text/plain;charset=UTF-8</value>     
                    <value>text/html;charset=UTF-8</value>     
                </list>     
            </property>     
		    </bean>
	   	</mvc:message-converters>
    </mvc:annotation-driven>

2.解决GET请求发送请求参数中文乱码解决方案


tomcat的server.xml文件,Connector标签增加useBodyEncodingForURI="true"属性即可。

猜你喜欢

转载自blog.csdn.net/ying_jh/article/details/73252607