???SpringMVC_03 利用SpringMVC提供的过滤器解决浏览器请求参数的乱码问题

时间:2023-03-09 18:27:07
???SpringMVC_03 利用SpringMVC提供的过滤器解决浏览器请求参数的乱码问题

1 响应乱码问题

  在启用mvc注解的配置中添加一个转换器配置

???SpringMVC_03 利用SpringMVC提供的过滤器解决浏览器请求参数的乱码问题

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
"> <mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven> <context:component-scan base-package="com.xunyji.spring_mybatis" /> </beans>