Results 1 to 2 of 2

Thread: Getting locale in MessageSource that extend ApplicationContextAware.

  1. #1
    Join Date
    Apr 2010
    Posts
    16

    Default Getting locale in MessageSource that extend ApplicationContextAware.

    Hi All,

    I have a class that implements applicationcontextaware that used to override the messageResource.getMessage feature. However now i have problem on getting the locale from the http://localhost:8080/test?lang=en. I have tried the LocaleContextHolder but it seems like getting the language from the browser itself rather than the param. And also i can't use RequestContextUtils.getLocale(request) as it need request which i dun not have. Any suggestion to deal with this ?

    Thanks in advance.

    Regards,

    Cyril

  2. #2
    Join Date
    Apr 2010
    Posts
    16

    Default

    Hi All,

    I still fail to get the locale from the request parameter : http://localhost:8080/test?lang=en.

    I tried with the RequestContextUtils.getLocale(request) but still getting the locale from browser setting as below :
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRe quest();
    Locale locale2 = RequestContextUtils.getLocale(request);

    My purpose is to able to load the correct i18n .properties file as i have implements my own MessageResource to resolve messages. Any help ?

    Regards,

    Cyril

Posting Permissions

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