spring - Spring4 internationalization multiple language -


http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/

trying follow online tutorial create multi language web application problem having don't think spring container finding / loading properties files. not sure wrong.

file structure

enter image description here

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} 

app-dispatcher-servlet: sure interceptors working because index.jsp ${pagecontext.response.locale} showing en/zh_cn

internationalization: multi lang support

resource: 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 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> 

but result in index.jsp is

enter image description here

where says "default text" should show "happy learning spring mvc" properties files.

change property file welcome.properties

welcome_en_us.properties 

it should work after that


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -