StrutsMessagesAndJSTL

HomePage | RecentChanges | Preferences

To use messages in ApplicationResources?.properties with JSTL's <fmt:message> tag:

in web.xml (Servlet 2.3)

  <!-- this is necessary for the JSTL <fmt:message> tags to work -->
   <context-param>
      <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
      <param-value>ApplicationResources</param-value>
   </context-param>

in struts-config.xml (Struts 1.2)

  <!-- ========== Message Resources Definitions =========================== -->
  <!-- This is the location of the ApplicationResources.properties file -->
  <message-resources parameter="ApplicationResources" null="false" />

and ApplicationResources?.properties is stored in WEB-INF/classes


<fmt:message key="button.sort"/>

[untested]
<fmt:message key="${someBean.propName}"/>


On 2005-11-22 on user@struts, Rahul suggests that this is not recommended and to use <fmt:setBundle> instead


HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited November 22, 2005 2:07 pm by WendySmoak (diff)
Search: