欢迎光临
我的个人博客

SpringMVC的get请求乱码

需要到tomcat的conf文件夹下的server.xml找到对应节点添加字符编码

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>

工程的web.xml增加节点

<filter>
<filter-name>SpringEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

转载请标明来源:ibear » SpringMVC的get请求乱码

分享到:更多 ()

Where there is a will there is a way

BladeX企业级开发平台