Spring i18n不起作用

时间:2017-02-02 20:09:42

标签: spring spring-mvc internationalization

当我使用标记时,我收到javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'welcome.message' for locale 'en_US'错误。

我的配置在/WEB-INF/dispatcher-servlet.xml中,看起来像这样

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages"/>
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>

<bean id="cookieResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en"/>
    <property name="cookieName" value="my-locale-cookie"/>
    <property name="cookieMaxAge" value="3600"/>
</bean>

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

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

我的邮件位于src/main/resources/messages.properties and messages_en_US.properties and messages_fr.properties.

0 个答案:

没有答案