Spring mvc编码配置

Spring3 MVC也带有自己的编码:

jar包:org.springframework.web-3.0.0.RELEASE.jar

只需要在web.xml配置即可:

<!-- spring mvc 解决中文编码的方法 -->
    <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>
    <!-- encoding filter for  page -->
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

 

posted @ 2014-10-22 16:49  勿妄  阅读(366)  评论(0编辑  收藏  举报