在web.xml中加入:

<!--  解决post乱码问题 -->
  <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>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

  过滤器扫描所有的文件,对其编码进行设置。

posted on 2018-12-26 16:29  wyhluckydog  阅读(204)  评论(0编辑  收藏  举报