如何重新加载JSF使用的ResourceBundle? [英] How to reload ResourceBundles that are used by JSF?

查看:224
本文介绍了如何重新加载JSF使用的ResourceBundle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在按钮点击时以编程方式重新加载JSF使用的ResourceBundles。类路径中的ResourceBundles(即WEB-INF / classes)由外部应用程序修改,修改事件对我来说是已知的。

I want to reload the ResourceBundles used by JSF programmatically on a button click. The ResourceBundles in the classpath (i.e. WEB-INF/classes) are modified by an external application and the modification event is known to me.

推荐答案

尝试

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

(你可以使用不带参数的相同方法)

(you can use the same method without arguments)

来自 javadoc


默认情况下,getBundle工厂方法创建的资源包实例会被缓存,如果有的话,工厂方法会多次返回相同的资源包实例被缓存了。 getBundle客户端可以清除缓存,使用生存时间值管理缓存资源包实例的生存期,或指定不缓存资源包实例。有关详细信息,请参阅getBundle工厂方法,clearCache,ResourceBundle.Control.getTimeToLive和ResourceBundle.Control.needsReload的说明。

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 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. Refer to the descriptions of the getBundle factory method, clearCache, ResourceBundle.Control.getTimeToLive, and ResourceBundle.Control.needsReload for details.

这篇关于如何重新加载JSF使用的ResourceBundle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆