How can i configure RestTemplate (Springframework) to encode using percent-encoding rather characters encoding, for example i am posting this parameters to a server:
client_id=xxx
client_secret=xxx
grant_type=client_credentials
scope=public_read registration
but when posting, spring send it as:
client_id=xxx&client_secret=xxx&grant_type=client_credentials&scope=public_read+registration
and i want it to be like that:
client_id=xxx&client_secret=xxx&grant_type=client_credentials&scope=public_read%20registration
it converts spaces to + and i want it to be %20
thx
You can use this:
String formated_urlString = URLEncoder.encode(unformated_url_string, "utf-8").replace("+", "%20").
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.