I have a controller that takes 2 parameters -
@PostMapping(value = "/myEndPoint")
public ResponseEntity<StreamingResponseBody> process(final InputStream data,
@RequestParam final String param1,
@RequestParam final String base64Param) {
return ok().body(doSomething(base64Param.getBytes(), param1, data));
}
The base64Param String parameter will contain +
characters, but of course the Spring controller replaces these with spaces.
Do you know how I can get around this and tell the controller to leave the +
characters alone?
UPDATE - I tried
UriComponentsBuilder builder = fromUriString(format("http://localhost:%s/%s", serverPort, "/myEndPoint"))
.queryParam("param1", param1)
.queryParam("base64Param", Base64.getUrlEncoder().encodeToString(base64ParamValueWithPluses.getBytes()));
but I'm having to decode the base64Param parameter in my controller like this -
String decodedBaseParam64 = Base64.getUrlDecoder().decode(encodeBaseParam64);
Is there a way to encode this so Spring will decode it automatically with the +
characters preserved?