struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "tim shaw (Created) (JIRA)" <>
Subject [jira] [Created] (WW-3690) i18n don't work in jsp pages (accessed directly) when locale changed
Date Sat, 08 Oct 2011 11:32:29 GMT
i18n don't work in jsp pages (accessed directly) when locale changed

                 Key: WW-3690
             Project: Struts 2
          Issue Type: Bug
          Components: Dispatch Filter, Expression Language, Value Stack
    Affects Versions:
         Environment: tomcat 6.x, java jre1.5 , struts- + xwork-2.1.6
            Reporter: tim shaw
            Priority: Critical

i found i18n tags in jsp pages rendered by action result work fine, but those in jsp pages
accessed directly( for example http://localhost/abc/xyz.jsp) can't work properly according
to the locale info which already set by the ActionContext.setLocale(locale).or ActionContext.getSession().set("WW_TRANS_I18N_LOCALE",locale)
in some action.execute() method before.

in my humble opinion, all of tags in jsp pages ( both accessed directly and rendered by some
action result) should work in accordance with some locale take procedences like that: 
1: evaluate the request locale. if there is no locale info,then:
2: evaluate the session locale, if there is no locale info ,then:
3: evaluate the default locale configed by StrutsConstants.STRUTS_LOCALE
4: if there are still no locale info ,then jre system properties will give a hand.


to found the problem, i navigated some code snipes  about the locale in struts
StrutsPrepareAndExecuteFilter.doFilter method line 78: prepare.createActionContext(request,
response); =>
PrepareOperations(Line 78) stack.getContext().putAll(dispatcher.createContextMap(request,
response, null, servletContext)); =>
Dispatcher(Line 535)  Map<String,Object> extraContext = createContextMap(requestMap,
params, session, application, request, response, context); =>
Dispatcher.createContextMap (line 568)

        Locale locale;
        if (defaultLocale != null) {
            locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
        } else {
            locale = request.getLocale();
here,locale will take precedence like that,first defaultLocale,then request.getLocale().
and thre result locale will be set in the ActionContext.setLocale()

at last the jsp i18n tags' propertes evaluated by DefaultTextProvider.getText(String),Here
is the code: 37 xwork-2.1.6.jar):
        return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale());

and i read the i18ninterceptor ,it will populate the ActionContext.locale by the session locale
if no local info given by the current request. (but as we know ,all interceptor will execute
only when we access some action!)
so from then on, it seemed that i found the weird i18n tags in direct accessed JSP pages,
because there are no further process for these direct accessed jsp pages ,just like the i18ninterceptor
for actions.

is there anything i missd or Is is a bug?

btw,my english could be better,sorry for that.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message