SpringMVC配置中文编码过滤器_前端

SpringMVC配置中文编码过滤器_配置参数_02

web.xml配置

<!--配置中文编码过滤器-->
    <filter>
        <filter-name>encode</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>
    <!--Request的强制编码设置为true-->
        <init-param>
            <param-name>forceRequestEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    <!--Response的强制编码设置为true-->
        <init-param>
            <param-name>forceResponseEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encode</filter-name>
    <!--拦截(过滤)所有路径-->
        <url-pattern>/*</url-pattern>
    </filter-mapping>