使用java程序检索语言环境信息

时间:2014-07-07 09:06:28

标签: java internationalization locale

是否可以在Spring bean中存储区域设置信息并在java应用程序中检索它?

...方案

我将传递locale参数和url,如下所示:

url?lang=fr

Spring context.xml配置如下所示:

<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>

<bean id="localeResolver"    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="cookieName" value="myAppLocaleCookie"/>
<property name="defaultLocale" value="fr" /> 
<property name="cookieMaxAge" value="604800"/>        

<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
  <property name="paramName" value="lang"/>
</bean>
</mvc:interceptors>

需要从我的java应用程序中的applicationcontext.xml中获取区域设置数据。 有没有办法将当前语言环境存储到.xml文件中的bean并在java应用程序中检索它。

我无法将更改的区域设置检索到我的java应用程序中。 如何更改我的java应用程序中的语言环境信息?

0 个答案:

没有答案