url = URLEncoder.encode(urlStr,"utf-8").replaceAll("\\+", "%20");
//encode会将空格替换为+号,所有要讲+号替换为空格的转义%20
url = url.replaceAll("%3A", ":").replaceAll("%2F", "/");
//encode会把url里的/和:这2个符号变成%2F和%3A 这里替换回来
本文共 249 字,大约阅读时间需要 1 分钟。
url = URLEncoder.encode(urlStr,"utf-8").replaceAll("\\+", "%20");
//encode会将空格替换为+号,所有要讲+号替换为空格的转义%20
url = url.replaceAll("%3A", ":").replaceAll("%2F", "/");
//encode会把url里的/和:这2个符号变成%2F和%3A 这里替换回来
转载于:https://www.cnblogs.com/songwen/p/3709642.html