字符串网址编码两次,我无法获得初始字符串



我必须编码一个已经部分编码的字符串。当我编码字符串时,它编码已经编码的字符的两倍。解码后,我无法返回字符串,因为它已经编码两次。

任何方法仅编码未加密字符?

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");

最新更新