web.xml设置编码

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

设置request编码为utf-8

还可以在<filter>节点中添加

<init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
</init-param>

表示是否同时设置response编码

 

posted @ 2015-04-12 12:22  sflik  阅读(609)  评论(0编辑  收藏  举报