提交中文乱码问题

post提交解决办法

1、web.xml中添加

<filter>
        <filter-name>encoding</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>  过滤器中需要的俩参数encoding和forceEncoding,需要配置属性值
            <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>encoding</filter-name>
        <servlet-name>springmvc</servlet-name>
    </filter-mapping>

2、html页面制定utf-8

1

2

3

<head>

  <meta charset="UTF-8">

 </head>

get方式请求的乱码,还需要在tomcat的8080端口添加

URIEncoding="UTF-8"

你可能感兴趣的