在Java中,如何在Web应用程序中动态重新加载资源包? [英] In Java, how to reload dynamically resources bundles in a web application?

查看:502
本文介绍了在Java中,如何在Web应用程序中动态重新加载资源包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用fmt:setBundle从数据库加载资源包(我们扩展了ResourceBundle类来做到这一点)。
当我们修改数据库中的值时,我们必须重新加载Web服务器以在Web应用程序上显示新值。

We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app.

有没有简单的方法可以使用新值而无需重新启动Web服务器?

Is there any simple way to use the new value without restarting the web server ?

(我们希望始终从数据库中查找值,但我们希望使缓存无效,例如通过调用特殊的'admin'URL)

(We do not want to always look up the value from database but we would like to invalidate the cache, for example by calling a special 'admin' URL)

编辑:我们使用的是JDK 1.4,所以我更喜欢该版本的解决方案。 :)

EDIT : We are using JDK 1.4, so I would prefer a solution on that version. :)

推荐答案

正如其他人在评论中指出的那样,你可能想看一下Spring - 特别是 ReloadableResourceBundleMessageSource

As others have pointed out in the comments, you might want to look into Spring - particularly the ReloadableResourceBundleMessageSource.

这篇关于在Java中,如何在Web应用程序中动态重新加载资源包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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