編集:私のSpringフレームワークバージョン3.0.5
ここでの小さな問題です。言語チェンジャーのリンクをクリックしても言語が変更されません。
言語ファイル(messages_xx.properties)は、クラスパスi18nディレクトリにあります。ファイルは次のとおりです。
i18n/messages_en.properties
i18n/messages_ar.properties
スプリング構成
<!-- Component scanner. This is used to automatically find Spring annotations like @Service and @Repository -->
<context:component-scan base-package="com.keype" />
<!-- Annotation driven programming model -->
<mvc:annotation-driven />
<context:annotation-config />
<mvc:resources mapping="/static/**" location="/static/" />
<!-- Session Object Configuration -->
<bean id="session" class="com.keype.system.Session" scope="session">
<aop:scoped-proxy />
</bean>
<!-- The View Resolver -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"
/>
<!-- i18n Configuration. Default language is english. Change language using ?language=en -->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<!-- Message text files. This is set UTF-8 to display Arabic UTF correctly. -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:i18n/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
JSPコードのセクション
<a href="?lang=ar"><spring:message code="header.arabic" /></a> |
<a href="?lang=en"><spring:message code="header.english" /></a>
問題は、上記のリンクをクリックして言語を変更すると、ロケール変更機能が機能しないことです。「defaultLocate」を「ar」に変更してテストしたところ、アラビア語のテキストが表示されます。
ここで何が間違っている可能性がありますか?Tomcatログにも何もありません。