You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chan Michael <mi...@yahoo.com.hk> on 2006/08/29 09:16:09 UTC
Reload ResourceBundle
Hi,
I am working on a web app using Struts 1.2.4 (+ Spring 1.2.6 + Tomcat 5.5.9). The app has two versions - English and Traditional Chinese. I use ResourceBundle + <bean> tag to achieve this.
Properties file
==========================================
WEB-INF/classes/message.properties
WEB-INF/classes/message_zh_TW.properties
==========================================
Now I want to update the properties files without reloading the app. I googled and found
Class klass = ResourceBundle.getBundle("message", locale).getClass().getSuperclass();
Field field = null;
try {
field = klass.getDeclaredField("cacheList");
} catch (NoSuchFieldException noSuchFieldEx) {
System.err.println(this.getClass().getName()+" : "
+noSuchFieldEx.getMessage());
}
field.setAccessible(true);
SoftCache cache = null;
try {
cache = (SoftCache)field.get(null);
} catch (IllegalAccessException illegalAccessEx) {
System.err.println(this.getClass().getName()+" : "
+illegalAccessEx.getMessage());
}
cache.clear();
field.setAccessible(false);
The above code snippet can be found in numerous places but unfortunately it doesn't work for me (no effect after executing).
Anyone help?
Thanks in advance.
Michael
_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
http://messenger.yahoo.com.hk