Warm tip: This article is reproduced from stackoverflow.com, please click
spring spring-mvc Thymeleaf

Get Thymeleaf @{} expression to append locale

发布于 2020-04-22 11:20:18

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?

Questioner
dtrunk
Viewed
93
dtrunk 2020-02-07 05:28

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