标签:
public static String encodeUrl(String source){ String result = source; try{ result = java.net.URLEncoder.encode(source,"utf-8"); }catch(UnsupportedEncodingException e){ e.printStackTrace(); } return result; }
实际运行结果:
public static void main(String[] args){ String oaurl = "http://127.0.0.1/wxshop/yh/src/goodList/details?gid=26"; System.out.println(encodeUrl(oaurl)); //http%3A%2F%2F127.0.0.1%2Fwxshop%2Fyh%2Fsrc%2FgoodList%2Fdetails%3Fgid%3D26 }
标签:
原文地址:http://www.cnblogs.com/codekey/p/4346000.html