ReloadableResourceBundleMessageSource.fallbackToSystemLocale不起作用

时间:2014-04-02 12:44:07

标签: java linux spring spring-mvc internationalization

我在使用i18n的应用程序中工作,这个应用程序在我的开发环境(Windows)中运行良好但是,当我尝试在Linux中部署时,一切似乎都没问题,直到我做了请求并收到消息

No message found under code 'message.header.inicio' for locale 'pt_BR'.

我有两个文件

  • messages_pt_BR.properties
  • messages_en.properties

经过大量研究后,我将messages_pt_BR.properties更改为messages.properties并将fallbackToSystemLocale设置为 false ,但我继续收到相同的错误。有人可以帮帮我吗?

关注我的dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
    http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">

<context:property-placeholder system-properties-mode="OVERRIDE" />
<context:component-scan base-package="br.com.company" />

<!-- i18n retirado de http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/ -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>

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

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:/br/com/company/web/i18n/messages"/>
    <property name="defaultEncoding" value="ISO-8859-1"/>
    <property name="fallbackToSystemLocale" value="false"/>
</bean>
<!-- referencias: http://www.mkyong.com/tutorials/spring-mvc-tutorials/ -->

<mvc:annotation-driven />
<mvc:resources location="/resources/" mapping="/resources/**" />

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    <property name="order" value="1" />
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>

<import resource="applicationContext-flow.xml"/>

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法。在spring标签中,我添加了text属性,即使在我的环境中,应用程序也会显示错误。我有一个后备的后备......

<spring:message code="welcome.springmvc" text="default text" />

这不是一个更好的解决方案,但有效。