使用Spring和Velocity进行i18n(国际化)的问题

我在使用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(瑞典语),它总是显示英语.

我正在使用Spring with Velocity.

任何的想法?
谢谢

解决方法:

这就是我做的:

>首先复制src / main / resources中的messages_xx.properties
我无法使用名称messages_xx_xx(messages_en_us)
>然后只需将以下配置添加到xxxx_servlet.xml上下文中

<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/>

>在我的* .vm中使用了#springMessages(‘message.title’)

就是这样.

上一篇:c# – 在接口上拦截


下一篇:Python基础