Search code examples
spring-mvcinternationalizationlocalemulti-tenant

Mask i18n and Theme parameters in URL


I have implemented i18n and theme using Locale and Theme resolver in Spring MVC.

So, all my normal URLs appear like

http://localhost/MyApp?lang=en&theme=red

Now, if I change the URL manually, the site reflects it immediately.

Is it possible to mask them, so, the User cannot change the language or theme by simply editing the URL?


Solution

  • You can use PRG(POST-Redirect-GET)-pattern. You will have to go on your page by POST request. And in your app create controller that will do all business and than redirect user to another address without your request params with GET-request and another controller. No user-changes than will affect your theme or language.