SpingMVC中文乱码解决

在web.xml配置以下节点,即可解决乱码

<!--过滤器处理乱码-->
  <filter>
    <filter-name>CharacterEncoding</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>CharacterEncoding</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

 

posted @ 2018-03-28 08:43  风骚少年  阅读(119)  评论(0编辑  收藏  举报
AmazingCounters.com