使用链接更改Spring MVC 3语言环境不起作用
|
编辑:我的Spring框架版本3.0.5
这里有个小问题,当我单击语言更改器链接时,语言没有更改。
语言文件(messages_xx.properties)在classpath 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日志中也没有任何内容。
没有找到相关结果
已邀请:
4 个回复
孝铜差
膝垫富顷
扭湘阀柿蹄
弓萍功
我遇到了同样的错误,并且使用此代码有效:-)