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不夠強大。它只是無法爲您提供資源。 –