Announcement Announcement Module
Collapse
No announcement yet.
Any idea why LocaleChangeInterceptor would suddenly no longer work? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Any idea why LocaleChangeInterceptor would suddenly no longer work?

    I've had the LocaleChangeInterceptor work great for months now. Suddenly, it no longer works and I can't understand why. I've uploaded my war file to another server, tested on a mac and a pc, it just doesn't change your locale when you add a language=en_US (or other locale) parameter to the URL anymore. I'm guessing some change I made having nothing to do with locales somehow affected this?

    This is what I have in my application-servlet.xml:
    Code:
        <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="language"/>
        </bean>
        <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
    And here is what I have in my treert-servlet.xml (treert is my app name):
    Code:
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="interceptors">
                <list>
                    <ref bean="localeChangeInterceptor"/>
                </list>
            </property>
            <property name="mappings">
                <value>
                     bunch of url -> controller mappings....
                </value>
            </property>
        </bean>
    The problem can't lie there because those have been unchanged for many months... What else might cause this to stop working? Everything else in my app works fine.

  • #2
    For others who may struggle with this issue, I fixed it by removing @RequestMapping("/servlet/path") in my controllers. I used to use the annotation mapping like that until I need to specify them in a specific order (for example, I have something like /servlet/path and /servlet/*, they need to be specified in that order for obvious reasons). So now i have them specified in my app-servlet.xml file, but I didn't remove them from my controllers, the xml file just took higher priority. That was working great until I added that request mapping to a few controllers who didn't have it for documentation purposes and for the hope that Spring would support specifying order or knowing the proper order in the future (maybe spring does and I don't know how to specify?).

    Comment

    Working...
    X