spring mvc 中文乱码

1、get提交出现乱码需要在tomcat 6 server.xml 文件 <Connector port="8080" 节点中添加 URIEncoding="UTF-8" 即可。

2、在web.xml中加入

<filter>
        <filter-name>Encoding</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>Encoding</filter-name>
        <url-pattern>/*</url-pattern>     </filter-mapping>
  
  
  
  

你可能感兴趣的:(spring,mvc,乱码)