Announcement Announcement Module
Collapse
No announcement yet.
Internationalization Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Internationalization

    Hello!

    I created basic Spring MVC application. I wanted to add internationalization to it, but it doesn't seems to work. It finds english text, but it doesn't change, when I want to switch to another language. I have added *.properties files to src/main/resources and configure beans in root-context.xml . Below are my beans configurations and I have uploaded project here.

    Thanks

    Beans:

    Code:
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
         <property name="basename" value="classpath:messages" />
         <property name="defaultEncoding" value="UTF-8"/>
    </bean>
    		 
    <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.CookieLocaleResolver">
         <property name="defaultLocale" value="en"/>
    </bean>
    		 
    <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
         <property name="interceptors">
              <ref bean="localeChangeInterceptor" />
         </property>
    </bean>

  • #2
    And why should it work.. The context is loaded by the ContextLoaderListener and the dispatcherservlet knows nothing about the reconfigured DefaultAnnotationHandlerMapping. Remove the DefaultAnnotationHandlerMapping from the root-context and simply configure the localChangeInterceptor in the servlet-context.xml.

    I suggest a read on the web chapter on how to use the mvc namespace to register interceptors (as that is what you are using).

    Comment

    Working...
    X