1. 程式人生 > >springmvc 表單提交到後臺亂碼問題

springmvc 表單提交到後臺亂碼問題

1:在web.xml里加上下面這句話,spring自帶的編碼格式

<!-- 編碼過濾器 -->

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

</filter-mapping>

2:如果再不行再修改這裡

修改tomcat的檔案

F:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\server.xml

    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"   URIEncoding="UTF-8"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"  URIEncoding="UTF-8"

/>
    -->