字符串url-编码两次,获取不到初始字符串
String url-encoded twice, I can't get the initial string
我必须对一个 URL 已经部分编码的字符串进行编码。当我对字符串进行编码时,它编码的字符是已经编码的两倍。解码后,我不能return到字符串,因为它已经被编码了两次。
有没有办法只对未加密的字符进行编码?
urlEncoded = URLEncoder.encode(id, "UTF-8");
要编码的示例url:
http://gastro-huc.org.pt/index.php?view=article&catid=41%3Ateses-de-mestrado&id=41%3Ateses-de-mestrado&format=pdf&option=com_content&Itemid=68
先解码再编码
String id = "http://gastro-huc.org.pt/index.php?view=article&catid=41%3Ateses-de-mestrado&id=41%3Ateses-de-mestrado&format=pdf&option=com_content&Itemid=68";
id = URLDecoder.decode(id);
String urlEncoded = URLEncoder.encode(id, "UTF-8");
我必须对一个 URL 已经部分编码的字符串进行编码。当我对字符串进行编码时,它编码的字符是已经编码的两倍。解码后,我不能return到字符串,因为它已经被编码了两次。
有没有办法只对未加密的字符进行编码?
urlEncoded = URLEncoder.encode(id, "UTF-8");
要编码的示例url:
http://gastro-huc.org.pt/index.php?view=article&catid=41%3Ateses-de-mestrado&id=41%3Ateses-de-mestrado&format=pdf&option=com_content&Itemid=68
先解码再编码
String id = "http://gastro-huc.org.pt/index.php?view=article&catid=41%3Ateses-de-mestrado&id=41%3Ateses-de-mestrado&format=pdf&option=com_content&Itemid=68";
id = URLDecoder.decode(id);
String urlEncoded = URLEncoder.encode(id, "UTF-8");