SpringMVC解决中文乱码问题

POST请求

web.xml中添加过滤器

复制代码
<filter>
    <filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
复制代码

GET请求

Tomcat中server.xml编码设置URIEncoding="UTF-8"

posted @   TIMEAWAY  阅读(83)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示