Java Spring MVC web app i18n

Java Spring MVC web app i18n,java,configuration,internationalization,spring-mvc,Java,Configuration,Internationalization,Spring Mvc,在使用SpringMVC编写的web应用程序中,我希望允许用户通过单击文本为语言名称的链接来更改当前语言 我已经设置了一个messageSource,并使我的所有jsp页面使用此messageSource查找消息。目前,该语言正在根据用户浏览器的区域设置进行更改 所以,我现在想做的是允许手动更改区域设置 我发现SessionLocaleResolver类可能会有所帮助,但我不知道如何在我的应用程序上下文文件(名称为myappnameservlet.xml)中设置它 我已经定义了bean: <

在使用SpringMVC编写的web应用程序中,我希望允许用户通过单击文本为语言名称的链接来更改当前语言

我已经设置了一个messageSource,并使我的所有jsp页面使用此messageSource查找消息。目前,该语言正在根据用户浏览器的区域设置进行更改

所以,我现在想做的是允许手动更改区域设置

我发现SessionLocaleResolver类可能会有所帮助,但我不知道如何在我的应用程序上下文文件(名称为myappnameservlet.xml)中设置它

我已经定义了bean:

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
</bean>


但是我应该在哪个bean中插入这个?此外,如何将与区域设置相关的cookie设置到用户会话中?

我需要的所有信息都在我面前的文档中,位于:

简言之,我将以下xml改编为myAppName-servlet.xml

<bean id="localeChangeInterceptor"
      class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="siteLanguage"/>
</bean>

<bean id="localeResolver"
      class="org.springframework.web.servlet.i18n.CookieLocaleResolver"/>

<bean id="urlMapping"
      class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="interceptors">
        <list>
            <ref bean="localeChangeInterceptor"/>
        </list>
    </property>
    <property name="mappings">
        <value>/**/*.view=someController</value>
    </property>
</bean>
更改整个站点的区域设置

例如:
在此处输入代码

siteLanguage=locale