http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/Spring4国际化多语言
试图遵循这一在线教程创建一个多语言的Web应用程序,我遇到的问题是,我不认为我的Spring容器找到/加载我的属性文件。我不知道什么是错的。
文件结构
welcome.properties
welcome.springmvc = Happy learning Spring MVC
welcome.properties
welcome.springmvc = \u5feb\u4e50\u5b66\u4e60 Spring MVC
的index.jsp
Language : <a href="?language=en">English</a>|<a href="?language=zh_CN">Chinese</a>
<h2>
welcome.springmvc : <spring:message code="welcome.springmvc" text="default text" />
</h2>
Current Locale : ${pageContext.response.locale}
应用,调度员的servlet: 我相信我的拦截器的工作,因为index.jsp的$ {} pageContext.response.locale是显示EN/ZH_CN
国际化:多郎支持
资源: http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/ http://howtodoinjava.com/spring/spring-mvc/spring-mvc-internationalization-i18n-and-localization-i10n-example/
http://www.technicalkeeda.com/spring-tutorials/spring-mvc-internationalization-i18n-example
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<mvc:interceptors>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
</mvc:interceptors>
<!-- <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" >
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean> -->
<!-- Register the welcome.properties -->
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="welcome" />
</bean>
<!-- ViewResolver JSP -->
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/html/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
但我的结果是的index.jsp
它说:“默认文本”应该真正从属性文件显示“快乐学习Spring MVC的”。
请澄清您的具体问题或添加其他详细信息,以确切地突出显示您的需求。正如目前所写,很难确切地说出你在问什么。请参阅如何问问页面以获取帮助以澄清此问题。 –
对不起,我编辑我的问题希望这个清楚的事情。如果你看最后截图的默认文本应该是属性文件中的“快乐学习Spring MVC”,但它显示“默认文本” –
Eric,Spring MVC不够强大。它只是无法为您提供资源。 –