1. GET的中文乱码问题在Tomcat中自动解决<br />POST的中文乱码问题,必须在没有获取request中的参数前,对请求的编码进行修改。<br />解决方式1:在web.xml中配置
    1. <!--配置编码过滤器-->
    2. <filter>
    3. <filter-name>CharacterEncodingFilter</filter-name>
    4. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    5. <init-param>
    6. <param-name>encoding</param-name>
    7. <param-value>UTF-8</param-value>
    8. </init-param>
    9. <init-param>
    10. <param-name>forceResponseEncoding</param-name>
    11. <param-value>true</param-value>
    12. </init-param>
    13. </filter>
    14. <filter-mapping>
    15. <filter-name>CharacterEncodingFilter</filter-name>
    16. <url-pattern>/*</url-pattern>
    17. </filter-mapping>

    解决方式2: