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



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM