
一开始以为是gzip配置问题,后来在后台打日志中看到是字符转码出现问题:
/**
* 字符转换
* @param str
* @return
* @throws UnsupportedEncodingException
*/
public static String characterEncode(String str) throws UnsupportedEncodingException{
String method = ParamUtil.getRequest().getMethod();
String systemChartCode = "UTF-8";
if ("get".equals(method.toLowerCase())){
return new String(str.getBytes("ISO-8859-1"),systemChartCode);
}else{
return str;
}
}
本来是没问题的,tomcat默认编码是ISO-8859-1,但是!!
<Connector executor="tomcatThreadPool"
URIEncoding="utf-8"
port="5095" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="3443" acceptCount="200"
compression="on"
compressionMinSize="50"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"/>
URIEncoding=”utf-8” 这个导致tomcat默认编码变成utf-8了,后续转码失败变成乱码。 |