Hi guys -
I'm having an issue using JSTL's <fmt:message ..> tag within Struts2.
I have set up multiple MessageResources using
and can successfully localize a message from these bundles in my main body of code usingCode:<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <value>classpath:/form</value> <value>classpath:/ApplicationResources</value> </list> </property> <property name="cacheSeconds" value="7200"/> </bean>
where 'ctx' is the ApplicationContext received via implementing the ApplicationContextAware interface. Up to here, everything is great.Code:ctx.getMessage("q.client.name.first", new Object[]{}, Locale.ENGLISH)
However, JSTL's <fmt:message ..> tag is unable to locate the resource bundle(s). I searched around and found Juergen's integration code in and around, and added a viewResolver to my appContextCode:org.springframework.web.servlet.support.JstlUtils
based on http://static.springsource.org/sprin.../JstlView.html, but to no effect. There are no other ViewResolvers defined in my context.Code:<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/> </bean>
The viewResolver may be doing something like executing JstlUtils.exposeLocalizationContext(...), which seems to be the missing link here, but I haven't had luck getting either the viewResolver to be recognized, or doing this call explicitly in an Interceptor or somewhere (for lack of a RequestContext).
One clue -- using the various Struts tags available for localization only succeeds for the <s:i18n> tag which allows the bundle name to be specified explicitly
I could just use this tag, but that would require a slew of code changes.Code:<s:i18n name="form"> <s:text name="q.client.name.first"/> </s:i18n>
Any ideas or suggestions? Thanks -
Kent


Reply With Quote
