【问题标题】:Simple Application Configuration with Stripes带条纹的简单应用程序配置
【发布时间】:2011-12-19 16:21:08
【问题描述】:

我正在使用条纹。我只想添加一些参数,这些参数将在应用程序启动时用于某些配置。最简单(或最好)的方法是什么?属性,web.xml 还是什么?我搜索了条纹书(也是网站),但找不到明确的答案。

我通常会像这样使用 appConfig.properties 文件和监听器类:

public class ConfigLoader implements  javax.servlet.ServletContextListener {

public void contextInitialized(ServletContextEvent sce) {
    Properties properties = System.getProperties();
    properties.put(sce, sce);
    try {
        properties.load(this.getClass().getResourceAsStream("appConfig.properties"));
        System.out.println(this.getClass().getResource("").getFile());

    } catch (IOException ex) {
        throw new ExceptionAdapter(ex);
    }        
}

public void contextDestroyed(ServletContextEvent sce) {
    throw new UnsupportedOperationException("Not supported yet.");
}

}

【问题讨论】:

    标签: web stripes


    【解决方案1】:

    Stripes 的好处在于,除了装订的小世界之外,它的占用空间也不大。所以你可以做任何你想做的事。如果您对 appConfig.properties 感到满意,那么请务必继续使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      • 2016-12-26
      相关资源
      最近更新 更多