解决方法
使用
ExternalContext#getResource()
或
ExternalContext#getResourceAsStream()
,其中传递webcontent相对路径.
例如.:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Properties properties = new Properties(); // ... properties.load(externalContext.getResourceAsStream("/WEB-INF/file.properties"));
这将委托给ServletContext#getResource()/ getResourceAsStream().
也可以看看:
> Where to place and how to read configuration resource files in servlet based application?