Reputation: 1142
I have a Spring MVC webapp and want to do this (example):
I already use the localeChangeInterceptor
to change the language by URL parameter on request, and this works (adding a parameter e.g. ?lang=en to my URLs).
But what is the best way to have language-specific subdomains with Spring? I searched the web and Spring documentation, but have yet to find an answer.
I think it could work like this:
localeChangeInterceptor
doesIf this is the way to go, I could use a hint where to start.
Thanks in advance!
Upvotes: 1
Views: 1147
Reputation: 6879
You will want to implement your own LocaleResolver.
The LocaleResolver.resolveLocale(HttpServletRequest) method is what Spring uses to determine which Locale to use from the MessageSource. You can extract the subdomain from the request and return the desired Locale.
Upvotes: 3