[Java][Play!] Retrieving Messages Defined in message Using Messages.get()

Tadashi Shigeoka ·  Wed, December 7, 2011

In Java’s Play! framework, to retrieve messages written in the message file from the controller, you can use the Messages.get() method.

For example, if you have a message file like this:

■ conf/messages

hello=Hello!
back=Back

You can write the following in the controller to retrieve values from the message file:

■ Controller

String msg = Messages.get("hello");
System.out.println(msg); // Outputs Hello!

That’s all from the Gemba.

【References】

Messages (Play! API)

Play framework - Documentation