Results 1 to 2 of 2

Thread: Is it possible to set Locale based on URL pattern?

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Default Is it possible to set Locale based on URL pattern?

    Hi all,

    I'm somewhat new to this stuff so be kind

    I would like to know if it is possible to have more than one URL map to a servlet/jsp and have the URL be used to set the Locale.

    For example

    www.foobar.com/foo-bar/MyFunkyServlet

    www.foobar.com/bar-foo/MyFunkyServlet

    So, the path /foo-bar/ should make the Locale be set to en_CA for example, while /bar-foo/ means the Locale is set to fr_CA. Ultimately the same Servlet/JSP is used for both, only a different resource bundle is loaded.

    Could someone let me know if this is possible, and possibly supply a short example (even if only in snippets) of how I might go about doing this?

    Thanks in advance for any replies!

    Cheers,
    Keith.

  2. #2
    Join Date
    Sep 2005
    Location
    João Pessoa, Paraíba - Brazil
    Posts
    5

    Default

    Well, using URL will be really hard, 'cos your controller maps requests using URL mappings and if you change them you might get into trouble.

    But, if you want to try something different, the first place to look is the LocaleResolver interface, it's the interface you will have to implement to change the way that a Locale is choosen: http://static.springframework.org/sp...eResolver.html

    Take a look at the avaliable implementations, don't try to write a new one if one of the avaliable classes suit your needs (one of them will probably do, but none use URL to resolve it).
    Coding: At the end of the day, if the program doesn\'t run and make money for the client, you haven\'t done anything.

Similar Threads

  1. MethodSecurityInterceptor not working?
    By asarco in forum Security
    Replies: 14
    Last Post: Mar 31st, 2008, 09:59 AM
  2. Replies: 11
    Last Post: Jun 1st, 2006, 04:30 PM
  3. Replies: 4
    Last Post: May 12th, 2006, 02:50 AM
  4. after login redirects incorrectly
    By ryan.tyer in forum Security
    Replies: 1
    Last Post: Oct 10th, 2005, 05:16 PM
  5. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM

Posting Permissions

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