Java – how to reload a resource package in a web application?

I use the resource bundle as a Java class to read values from the database When I update dB, I need to reload the bundle, but I don't know how Can I help you

package model.helpers;
public class Messages_en extends ListResourceBundle {
      protected Object[][] getContents() {
            // from DB
            // ...
      }
}

In the view, I use bundles as follows:

<f:loadBundle basename="model.helpers.Messages" var="m" />

Solution

ResourceBundle.clearCache();
ResourceBundle.clearCache();

or

Messages_en .clearCache();

Calling this method will reload the resource and it will refresh the bundle

> Reference

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>