Two Laptop Bag*
The moose likes Struts and the fly likes how to read .properties file from action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to read .properties file from action class" Watch "how to read .properties file from action class" New topic
Author

how to read .properties file from action class

zimbu bolleddu
Ranch Hand

Joined: Jan 14, 2008
Posts: 35
Hi all,

I'm new to struts,

I want to read key/value pair to String object in action class.

I'm able to read it in jsp like <jsp:message key=form.msg>

but not in action class.

thanks in advance ..!
Suresh Kumar
Greenhorn

Joined: May 26, 2008
Posts: 6
Hi,

You can use MessageResources to read the properties file in Action class.
In execute method, you can give like this..
MessageResources msgResource = getResources(request);
This will read the message resource file specified in struts-config.xml
(<message-resources parameter="ApplicationResources"/>

Then you can use getMessage() method on MessageResources to fetch the messages.

Regards,
Suresh.
zimbu bolleddu
Ranch Hand

Joined: Jan 14, 2008
Posts: 35
very many thanks

it is working fine.....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to read .properties file from action class