色粉盒撒娇 发表于 2017-1-18 10:28:59

jsp + tomcat 中文乱码解决

1.保证JSP页面已经设置为utf-8;
2.
request.setCharacterEncoding("UTF-8")
response.setCharacterEncoding("UTF-8")

或是写一个字符过滤器,在web.xml中调用;

3.最为重要的tomcat配置
在tomcat安装目录下的conf/server.xml文件中
找到节
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"      
               redirectPort="8443" />
添加一个属性 useBodyEncodingForURI="true"
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
       useBodyEncodingForURI="true"
               redirectPort="8443" />
页: [1]
查看完整版本: jsp + tomcat 中文乱码解决