java.lang.IllegalArgumentException : urlcoder exception resolution

Exception:

Exception in thread “main” java.lang.IllegalArgumentException : URLDecoder: Illegal hex characters in escape (%) pattern – For input string: “u9”
    at java.net.URLDecoder .decode( URLDecoder.java:194 )
    at com.hbzx.controller . PayResultController.main ( PayResultController.java:253 )
reasons:

Java call URLDecoder.decode (STR, “UTF-8”); the main reason for throwing the above exception is that% is a special character in the URL and needs special escape,

Solution: replace the% sign in the string with% 25

solve:

 url = url.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
   String urlStr = URLDecoder.decode(url, "UTF-8");

D-page address: https://blog.csdn.net/afgasdg/article/details/40304817

Read More: