[英]LocaleResolver in Spring
I am using session locale resolver for my application. 我正在为我的应用程序使用会话语言环境解析器。 I am showing the languages in dropdown.
我在下拉菜单中显示语言。 if the user selects on any of the language then repopulates all values from that language.
如果用户选择任何一种语言,则从该语言重新填充所有值。
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="languageCode" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
But its is not reading it from the session. 但是它不是从会话中读取它。 Always it considers the defaultlanguage from browser setting.
始终会考虑浏览器设置的默认语言。 Please help on this.
请帮忙。
您需要通过以下方式获取语言环境:
Locale loc=RequestContextUtils.getLocale(request);
在Spring 4.0中,我们也可以使用LocaleContextResolver.getLocale()
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.