url转义时,大部分只需要将url中的中文进行编码,记录一下方法,不是自己写的,但用着挺好。
链接记不住了, 如有侵权,请留言。
Matcher matcher = Pattern.compile("[\\u4e00-\\u9fa5]").matcher(url);
while (matcher.find()) {
String chn=matcher.group();
url=url.replaceAll(chn,encode(chn,"gbk"));
}
return url;