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