我在使用 Spring 设置国际化时遇到问题。
这是我的配置。
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="localization" />
</bean>
<!-- declare the resolver -->
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="sv" />
</bean>
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<mvc:annotation-driven />
即使我用
?locale=sv
请求,它也总是向我显示英语(瑞典)。我正在使用带有 Velocity 的 Spring。
任何的想法?
谢谢
最佳答案
这就是我所做的:
messages_xx.properties
在 src/main/resources
我无法使用名称 messages_xx_xx
(messages_en_us) <bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<mvc:interceptors>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang"/>
</bean>
</mvc:interceptors>
<mvc:annotation-driven/>
#springMessages('message.title')
在我的 *.vm
就是这样。
关于spring - Spring 和 Velocity 的 i18n(国际化)问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6413688/