Can someone please explain to me what is happening in the following code?
If I run:
RestTemplate rest = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.add("header1", "data"); headers.add("header2", "data"); HttpEntity<String> entity = new HttpEntity<>("body", headers); ResponseEntity<JSONObject> response = rest.exchange("https://example.com/../{username}/{path}", HttpMethod.GET, entity, JSONObject.class, "user%123", "path");
Spring tells me that the URL used is https://example.com/../username/path where username = user%25123 even though I set the username = user%123.
This is looking to me to be not a Spring issue, rather a URL encoding issue, but can anyone tell me where this extra 25 comes from?
Advertisement
Answer
%25
is a URL-encoded percent sign, so user%123
encodes to user%25123