Announcement Announcement Module
No announcement yet.
Any idea why LocaleChangeInterceptor would suddenly no longer work? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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:
        <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="language"/>
        <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):
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="interceptors">
                    <ref bean="localeChangeInterceptor"/>
            <property name="mappings">
                     bunch of url -> controller mappings....
    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?).