Results 1 to 4 of 4

Thread: LocaleChangeInterceptor not working

  1. #1
    Join Date
    Nov 2008
    Posts
    232

    Default LocaleChangeInterceptor not working

    I had a web application using spring mvc running successfully on Tomcat .Now i am migrating the same to spriing-dm 2.

    I was using LocaleChangeInterceptor to set locale based on request param.
    Under tomcat it was working fine .But now under dm-server locale is not getting changed based on request param

    My setup looks like this

    servlet-context.xml
    Code:
    	<context:component-scan base-package="com.xyz.controllers" />
    
    	<mvc:annotation-driven conversion-service="conversionService" />
    	
    	
    
    	<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
    
     
    	<bean id="messageSource"
    		class="org.springframework.context.support.ResourceBundleMessageSource">
    			<property name="basenames" value="messages,static" />
    	</bean>
    
    
    	<bean id="localeChangeInterceptor"
    		class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    		<property name="paramName" value="locale" />
    	</bean>
    
    
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/jsp/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    
    	
    	<bean id="localeResolver"
    		class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />
    
    	<bean id="urlMapping"
    		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    		<property name="interceptors">
    			<list>
    				<ref bean="localeChangeInterceptor" />
    			</list>
    		</property>
    	</bean>
    MANIFEST.MF
    Code:
    Web-ContextPath: /
    Import-Library: org.springframework.spring

  2. #2
    Join Date
    Nov 2008
    Posts
    232

    Default

    One more thing i noticed it ,
    when i remove
    <mvc:annotation-driven conversion-service="conversionService" />
    <bean id="conversionService" class="org.springframework.format.support.Formatti ngConversionServiceFactoryBean" />

    from my servlet-context.xml

    LocaleChangeInterceptor is working fine But now my NumberFormatiing is lost

    Regards,
    Vishal

  3. #3
    Join Date
    Feb 2009
    Location
    Hursley, near Winchester, UK
    Posts
    37

    Default

    Hi Vishal,
    I think this is a Spring issue rather than a dm Server one -- I found a reference in the Core Spring Projects -> Web forum Conflict between <mvc:annotation-driven> and DefaultAnnotationHandlerMapping which throws some light on this.

    One piece of advice was to use mvc:interceptors rather than annotation-driven if all you wish is to add interceptors -- there appears to be a problem with annotation-driven overriding the DefaultAnnotationHandlerMapping, leaving your interceptors high-and-dry.

    This thread references jira issue SPR-6524.

    Steve Powell

  4. #4
    Join Date
    Nov 2008
    Posts
    232

    Default

    Thanks for the reply
    I added <mvc:interceptors> and it worked for me .

    Regards,
    Vishal

Posting Permissions

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