- 设置过滤器编码为utf-8
tomcat -> conf -> server.xml文件
uriEncoding="UTF-8"
- 如果过滤器编码为其他编码格式,比如GBK,那么在程序中必须进行转码
name = new String(name.getBytes("GBK"),"utf-8");
- 如果没有设置过滤器编码,那么在程序中可以通过两种形式进行转码
name = new String(name.getBytes("iso-8859-1"),"utf-8");
2023-11-20 09:36:16
tomcat -> conf -> server.xml文件
uriEncoding="UTF-8"
name = new String(name.getBytes("GBK"),"utf-8");
name = new String(name.getBytes("iso-8859-1"),"utf-8");