I have created a java maven web application. Now my problem is that I have to access a properties file using resource bundle or Properties class. But this properties file is in webapp/resources folder i.e. in the same directory as my js and css files.
I have this utility method but I can write new ones if required:
public static ResourceBundle getBundle(String baseName, String absolutePath) {
File file = new File(absolutePath);
ResourceBundle bundle = null;
try {
URL[] urls = { file.toURI().toURL() };
ClassLoader loader = Thread.currentThread().getContextClassLoader();
bundle = ResourceBundle.getBundle(baseName, Locale.getDefault(), loader);
} catch (MalformedURLException e) {
}
return bundle;
}
My project structure:
-project
-------src
--------main
---------java
---------resources
---------webapp
----------resources
-----------app.properties
-----------script.js