Reputation: 29
I am converting an application from struts 1 to Spring MVC and I am trying to figure out what to do in my Java code when its using the import org.apache.struts.config.MessageResourcesConfig and org.apache.struts.util.MessageResources. In the spring-servlet.xml file I added the line to include my message resources properties file but I am not longer going to use the struts 1 libraries. How would I go about the conversion of this part of the code?
It is used a good bit throughout the application such as places like this:
this.config = new MessageResourcesConfig();
this.config.setParameter("path that was used here was set in the spring-servlet configuration file");
this.resources = MessageResources.getMessageResources(this.config.getParameter());
Upvotes: 0
Views: 1049
Reputation: 13893
I would refactored the way you load the Resources using java.util.ResourceBundle
// load resourcebundle.properties
bundle = ResourceBundle.getBundle("resourcebundle");
You can then get a value using
String val = bundle.getString(key);
You can have an helper class to get the values you need, and/or find a way to pass it to the JSP (cannot help you there, sorry)
Upvotes: 1