Announcement Announcement Module
Collapse
No announcement yet.
Getting locale in MessageSource that extend ApplicationContextAware. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment

    Working...
    X