Differences between revisions 1 and 2
Revision 1 as of 2006-07-22 03:00:57
Size: 1472
Revision 2 as of 2009-09-20 23:11:56
Size: 1476
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 51: Line 51:
 * [http://www-128.ibm.com/developerworks/java/library/j-jstl0415/ A JSTL primer: Message Resources]
 * [http://www.systemmobile.com/?p=200 Struts Message Resources]
 * [[http://www-128.ibm.com/developerworks/java/library/j-jstl0415/|A JSTL primer: Message Resources]]
 * [[http://www.systemmobile.com/?p=200|Struts Message Resources]]

<bean:message> is used to display a localized and possibly parameterised message from a property file bundled with application.

Common Setup

Resource files should be names according to locale and country, like:

  • Messages_en.properties -- English language
  • Messages_fr.properties -- French language
  • Messages_fr_CA.properties -- French language, Canadian dialect

Struts Taglib


<message-resources parameter="com.acme.webboard.Messages"/>

JSP file:

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<%-- No arguments --%>
<bean:message key="webboard.greeting"/>

<%-- Passing arguments to a message in a JSP2.0 container --%>
<bean:message key="webboard.greeting" arg0="${user.name}"/>




JSP file:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<%-- No arguments --%>
<fmt:message key="webboard.greeting"/>

<%-- Passing arguments to a message --%>
<fmt:message key="webboard.greeting"/>
  <fmt:param value="${user.name}"/>

More information:

JSTLTagsBeanMessage (last edited 2009-09-20 23:11:56 by localhost)