I have a Spring-Boot (1.5.3) application running on a Tomcat 8.5. Within it, i have a RestController with a single parameter.
This parameter is decoded automatically - which is fine for all other controllers within my application, but for this one, i need the raw request data, since they will be used within another request. Please note that i wold like to only disable the auto-decoding for this Controller/request and keep the normal behaviour everywhere else.
@RestController
@RequestMapping("/rest/test")
public class TestController {
@RequestMapping("/test")
public ResponseEntity<String> test(@RequestParam final String test){
return ResponseEntity.ok("Requested: " + test);
}
}
Now, if i send access it with
curl localhost/rest/test/test?test=%C3%B6%20%C3%A4
I receive the output:
Requested: ö ä
I would like to have
Requested: %C3%B6%20%C3%A4
Any Ideas?
If you need this behavior only in a single place, you can encode the parameter back to the original form using the standard Java URLEncoder inside of the controller body:
@RequestMapping("/test")
public ResponseEntity<String> test(@RequestParam final String test) {
String encodedParam = URLEncoder.encode(test, "UTF-8");
return ResponseEntity.ok("Requested: " + encodedParam);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments