Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1045

Spring Boot Umlaute in Redirect URL

$
0
0

2024 and still problems with encoding UTF-8. Here's my problem reduced to a very simple project with tests (just two important classes, rest is boilerplate created with Spring Initalizr):

https://github.com/kicktipp/springumlaut

I have a redirect in a SpringBoot App which contains an German Umlaut like "ö".

@GetMapping("/hallo")public String hallo() {    return "redirect:/hallöchen";}@ResponseBody@GetMapping("/hallöchen")public String helloWithUmlaut() {    return "Hallöchen";}

Running with the default Tomcat engine I get an status code 400 with the message

java.lang.IllegalArgumentException: Invalid character found in therequest target [/hall0xc30xb6chen ]. The valid characters are definedin RFC 7230 and RFC 3986

The error is thrown in CoyoteAdapter in the method convertURI line 1068 and it says in the comment, that this should never happen:

// Should never happen as B2CConverter should replace// problematic charactersrequest.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);

In my test where I call the URL with Umlaut directly everything works fine.

Why does not Spring Boot encode this URL properly, so everything works out-of-the-box and how can I fix it in the most easy and standard way?


Viewing all articles
Browse latest Browse all 1045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>