【发布时间】:2014-03-01 14:13:55
【问题描述】:
我正在尝试在运行时重新加载资源包。
在我的应用程序中,登录后,我得到了调用<f:loadBundle basename="messages" var="msg" /> 的属性。调用是在我的应用程序基础模板中进行的,一切正常。属性文件位于 MyApp/resources/ 下
下一步是尝试更新从我的 userHome/resources 中的属性文件读取的 resourceBundle。我正在调用我的托管 bean 是:
File file = new File(System.getProperty("user.home")+ "/resources/");
URL[] urls = {file.toURI().toURL()};
ClassLoader loader = new URLClassLoader(urls);
ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());
ResourceBundle.clearCache();
bundle = ResourceBundle.getBundle("messages",Locale.ENGLISH, loader);
我没有收到任何错误,并且边界得到了正确的值,但是我的应用程序中发生了任何更改。有人可以告诉我如何重新加载捆绑包并显示我从外部文件中获得的新值??清除缓存似乎不起作用,我摆脱了jsf2的faces-config.xml原因......希望有人能提供帮助。
【问题讨论】:
-
一件事是以编程方式加载捆绑包。另一件事是在更新它们时让它们保持刷新。我想你的目标是第二个?
-
是的,我想在每次更改用户/资源下的属性文件时刷新它们
标签: jakarta-ee jsf-2 jboss resourcebundle clear-cache