spring下post和get请求乱码问题解决

post请求

添加web.xml配置如下

<!-- 设置字符集 -->
<filter>
    <filter-name>CharacterEncoding</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-parm>
</filter>
<!-- 设置过滤的类型 -->
<filter-mapping>
    <filter-name>CharacterEncoding</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

get请求

修改server.xml配置(Tomacat配置)

打开server.xml文件找到第一个Connector标签,添加上URIEncoding="UTF-8"

Last modification:September 5th, 2020 at 07:40 pm