message
Implements a body tag allowing the usage of a resource bundle to internationalize content in a web page. The key attribute is required, and is used to look up content in the resource bundle. The args attribute is optional, and if present, provides items to pass to a MessageFormat. The
bundle tag must be used first in order to ensure that the proper bundle is loaded.
Library
i18n
Tag class
org.apache.taglibs.i18n.MessageTag
Attributes
Table 7‑10 lists and describes the attributes for message.
Table 7‑10 Attributes for message
Attribute | Required | Description |
args | No | An array of arguments for use with java.text.MessageFormat when formatting the display text |
bundle | No | Object reference to the ResourceBundle in which the key can be found |
bundleRef | No | Name of an attribute that contains a resource bundle |
key | Yes | Key to use when retrieving the display message format from the ResourceBundle |
Used in
<context root>\errors\pagenotfound.jsp
Variables
Table 7‑11 describes the variable for message.
Table 7‑11 Variable for message
Variable | Description |
id | id allows other tags or scriptlets to access the String created by this tag. If id is specified the String is not printed by this tag, just stored into the id. |
Example
The following example displays a plain message using the default (first defined) bundle:
<i18n:message key="column1.header"/>
The next example displays a plain message using a specified bundle. In this example the default bundle is bundle1 because it is defined first:
<i18n:bundle baseName="com.mycorp.taglibs.i18n.i18n-test"
id="bundle1"/> <!-- the default -->
<i18n:bundle baseName="com.mycorp.taglibs.i18n.i18n-test2"
id="bundle2"/> <!-- the alternate -->
<i18n:message key="column1.header" bundle="<%= bundle2 %>" />