|
Looks up and returns the localized message for the specified key.
String get(String key, Object args[])
|
String get(String key, List args)
|
- Parameters
-
- key
-
Message key.
- args
-
Replacement parameters for this message. Typically
an array of Strings or a List of Strings (but any
Object with a reasonable
toString()
method can be used).
- Returns
-
The localized message for the specified key. Returns null if no
message exists for the key passed.
- See Also
-
Struts user's guide on
Internationalized Messages.
The user's locale is consulted to determine the language of the
message. The second and third signature take a list of up to five
replacement parameters. The second signature is provided for compatibility
with existing applications. The third signature is Velocity-friendlier.
Assuming that the message resource files contain the following messages:
title=Welcome to Velocity for Struts
test=This message has five replacement parameters: {0}, {1}, {2}, {3}, {4}
|
|
then the following Velocity script:
$msg.get("title")
$msg.title
$msg.get("test", ["bear", "wolf", "tiger"])
|
|
produces this output:
Welcome to Velocity for Struts
Welcome to Velocity for Struts
This message has five replacement parameters: bear, wolf, tiger, {3}, {4}
|
|
|