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://blog.csdn.net/jiangjunshow

相关文章