background:
When the system calls a third-party interface and the parameters sent contain a space key " ", the service provider cannot recognize the parameters and will report an error. Therefore, URLEncoder and URLDecoder encrypt and decrypt the request parameters, but an error will be reported later:
URLDecoder: Illegal hex characters in escape (%) pattern - For input string: “%“
reason:
When the encryption parameter contains % or +, the URLDecoder.decode() method will report an error. If you want to know why, you can check the source code of the method.
solve:
Make a judgment. If the parameter contains % or +, skip it, or replace it and then decode it.