LocaleChangeInterceptor - probably easy to solve for the right person
Hello fellow Spring programmers.
I just took the first step into the area of internationalization, where i will be preparing a Spring MVC application for multi-language use. I googled and read a few examples (like this one: http://viralpatel.net/blogs/spring-3...orial-example/) and it seems pretty straightforward. I used the exact same setup from this example and the code from the fix referenced in it. I have seen this same setup in a number of posts on different forums.
The one thing i don't fully understand is this: I have a controller method with a mapping that looks like this:
Code:
@RequestMapping(value = "/placeDetails.htm", method = RequestMethod.GET) public String showPlaceDetails(Model model, @RequestParam(value = "placeId", required = true) int placeId, Locale locale) {
It would catch a request like this one: www.me.com/placeDetails.htm?placeId=123.
The href that i add to the "change language" menu item says href="?lang=en". As far as i can see, i end up with the URL www.me.com/placeDetails.htm?lang=en (i see this when i hover over the menu item). The method's request mapping above will not recognize this and i get an error message from Tomcat saying "The request sent by the client was syntactically incorrect ().". My controller knows of no call to www.me.com/placeDetails.htm with a parameter called lang.
It was (and still is) my assumption that i should not have to add another method with a request mapping that includes the lang parameter. I assumed the LocaleChangeInterceptor would intercept this call and handle it.
So my question is: am i making the right assumption and if i am not, how is the interceptor supposed to work when the controller method has other parameters. If i am making the right assumption - any ideas why this is not working.