I follow Spring mvc course on Pluralsight, and I have "Cannot change HTTP accept header - use a different locale resolution strategy" this error when running my application. Before this, I added theese beans to servlet-config.xml
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="language" />
</mvc:interceptors>
<bean id="localResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" p:defaultLocale="en" />
In resource folder I have two files. messages_es.properties and messages.properties. One hasgoal.text=Minutos Ejercicio para el día de hoy:
and other goal.text=Minutes Exercise For The Day Today:
So the target is to choose the language.
And in jsp file I have this line about it
Language : <a href="?language=en">English</a> | <a href="?language=es">Spanish </a>
So how can I make it work correctly?
Change the bean id from "localResolver" to "localeResolver"
I solved this issue by naming the method as localeResolver using the solution provided here Spring 4 i18n & l10n (Cannot change HTTP accept header)
@Bean
public LocaleResolver localeResolver()
{
final SessionLocaleResolver localeResolver = new SessionLocaleResolver();
localeResolver.setDefaultLocale(new Locale("en", "US"));
return localeResolver;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With