java.lang.IllegalArgumentException : urlcoder exception resolution


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

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


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

D-page address:

Read More: