






















原先以为这样就可以
public static String StrToURL(String str) {
String result = null;
try {
result = URLEncoder.encode(str, "utf-8");// gb2312
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
public static String URLtoStr(String url) {
String result = null;
try {
result = URLDecoder.decode(url, "utf-8");
// 空格替换成加号
result = result.replaceAll(" ", "+");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
没想到中文还是乱码,通过抓包发现传过来的东西没错,发现是tomcat的问题,加了下面的就可以了
<Connector port="8236" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8" />
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。