gpt4 book ai didi

spring - Spring 和 Velocity 的 i18n(国际化)问题

转载 作者:行者123 更新时间:2023-12-01 04:10:44 24 4
gpt4 key购买 nike

我在使用 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.propertiessrc/main/resources我无法使用名称 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/>
  • 二手 #springMessages('message.title')在我的 *.vm

  • 就是这样。

    关于spring - Spring 和 Velocity 的 i18n(国际化)问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6413688/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com