Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > Generic Tag Reference > text |
Render a I18n text message.
The message must be in a resource bundle with the same name as the action that it is associated with. In practice this means that you should create a properties file in the same package as your Java class with the same name as your class, but with .properties extension.
If the named message is not found in a property file, then the body of the tag will be used as default message. If no body is used, then the stack will be searched, and if a value is returned, it will written to the output. If no value is found on the stack, the key of the message will be written out.
For more details on using resource bundles with Struts 2 read the localization guide.
Dynamic Attributes Allowed:false | |||||
Name | Required | Default | Evaluated | Type | Description |
---|---|---|---|---|---|
id | false | false | String | Deprecated. Use 'var' instead | |
name | true | false | String | Name of resource property to fetch | |
searchValueStack | false | true | false | Boolean | Search the stack if property is not found on resources |
var | false | false | String | Name used to reference the value pushed into the Value Stack |
Other example
where the following is in a regular (possibly locale-specific) properties file:
For more about formatting text, see
This will not work:
Instead, you should use the getText() method that you inherit when your Action extends XWork's ActionSupport: