I've created a webapp using Spring MVC. I've set up internationalization through an interceptor in my dispatcher serlvet like this:
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="es" />
</bean>
Then I can access current locale in my controllers like this:
LocaleContextHolder.getLocale()
Which is awesome, because I can then change my locale at any point and access current config anywhere.
Now I would like to do the same with some custom variables that behave in a similar fashion, in the sense that they slightly affect all of my app's behavior. (e.g. an "accesible" parameter indicates the app it should offer only accesible content).
I understand I can create my own interceptor to intercept any param named "accesible" like so:
<bean id="localeChangeInterceptor" class="com.myapp.MyInterceptor">
<property name="paramName" value="accesible" />
</bean>
But is there a way that I can access this value throughout my app like the LocaleContextHolder object does with locale? Can I make Spring inject it through a Cookie likeso?