简体   繁体   English

如何重新加载JSF使用的ResourceBundle?

[英]How to reload ResourceBundles that are used by JSF?

I want to reload the ResourceBundles used by JSF programmatically on a button click. 我想在按钮单击时以编程方式重新加载JSF使用的ResourceBundles。 The ResourceBundles in the classpath (ie WEB-INF/classes) are modified by an external application and the modification event is known to me. 类路径中的ResourceBundle(即WEB-INF / classes)由外部应用程序修改,修改事件对我来说是已知的。

Try 尝试

ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());

(you can use the same method without arguments) (你可以使用不带参数的相同方法)

From the javadoc 来自javadoc

Resource bundle instances created by the getBundle factory methods are cached by default, and the factory methods return the same resource bundle instance multiple times if it has been cached. 默认情况下,getBundle工厂方法创建的资源包实例会被缓存,如果已缓存,则工厂方法会多次返回相同的资源包实例。 getBundle clients may clear the cache, manage the lifetime of cached resource bundle instances using time-to-live values, or specify not to cache resource bundle instances. getBundle客户端可以清除缓存,使用生存时间值管理缓存资源包实例的生命周期,或指定不缓存资源包实例。 Refer to the descriptions of the getBundle factory method, clearCache, ResourceBundle.Control.getTimeToLive, and ResourceBundle.Control.needsReload for details. 有关详细信息,请参阅getBundle工厂方法,clearCache,ResourceBundle.Control.getTimeToLive和ResourceBundle.Control.needsReload的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM