在使用URLDecoder對字符串進行解碼的時候 報以下異常信息:
Exception in thread "main" java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
原因是字符串中包含有%字符
解決方法如下 example:
String str = "hello該字符串中包含%"; System.out.println(URLDecoder.decode(str.replaceAll("%", "%25"), "UTF-8"));
常見URL編碼表: