URLDecoder: Incomplete trailing escape (%) pattern

在使用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编码表:


原文地址:https://www.cnblogs.com/itmyhome/p/4131319.html