Results 1 to 2 of 2

Thread: Internationalization

  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •