Reputation: 1
I have a property file that is bundled in an external jar file in my WEB-INF/lib. If I want to override the values in that property file and use my own values from my own property file. Is there a better way to do it. For example: in the default property file, I see
banner.ad.link=<a href="{1}" title="Click here {0}">{0}</a>
I want to change it to something like:
banner.ad.link=<a class="mycss" href="{1}" title="Click here {0}">{0}</a>
So far this is what I have:
public class MainListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event)
{
ResourceBundle bundle = ResourceBundle.getBundle("com.comResources");
bundle = ResourceBundle.getBundle("org.displaytag.messages",
Locale.getDefault());
for (Enumeration<String> e = bundle.getKeys(); e.hasMoreElements() ;) {
System.out.println(e.nextElement());
}
}
}
I'm not too sure where to go from here to override the key value pair from the bundle object to have a new value from my own property file. Any help, I would be greatly appriciated! Thanks in advance!
Upvotes: 0
Views: 1169
Reputation: 691635
I see three ways of doing it.
Note that if all you want to do is to customize displaytag, you just have to put your displaytag.properties at the root of the classpath (i.e. in the default package) rather than in the org.displaytag.properties
package, as documented here. Displaytag will load your bundle rather than the default one if found.
Upvotes: 1