Search code examples
springspring-mvcthymeleaf

Get Thymeleaf @{} expression to append locale


My context path is / and I'm adding locales directly as part of the path: /de/index.html.

Now I'm facing the problem that th:href="@{/login.html}" will resolve to /login.html instead of /de/login.html.

I already tried making a Filter and an Interceptor like they did it here: https://stackoverflow.com/a/23847484/1163457

But it still won't append de/ after the context path.

Writing my own dialect and attribute processors would be a solution, but isn't there any better one?


Solution

  • I found a clean and good solution myself after hours of step debugging: https://stackoverflow.com/a/60103777/1163457