JSP消息代码中的多个资源包

时间:2013-11-22 23:25:03

标签: java spring spring-mvc

我正在使用Spring MVC 3.我有以下格式的消息包:

message_en_US.properties
message_en.properties
message_USA.properties

在我使用的JSP中:

现在,查找值的顺序应该是en_US,然后是en属性USA属性文件。 我该如何定制?

1 个答案:

答案 0 :(得分:0)

您应该使用以下配置。因此,如果要设置默认语言,可以使用第二种语言。

在我的src / main / resources中,我有mymessages_en_US.properties和mymessages_es_ES.properties

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <array>
            <value>classpath:mymessages</value>
        </array>
    </property>
    <property name="defaultEncoding" value="UTF-8" />
    <property name="cacheSeconds" value="0" />
</bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="es_ES" />
</bean>
相关问题