我在java中有一个Web应用程序项目。如果我部署项目,那么项目有Tomcat服务器上的文件夹层次的结构如下:如何从文件夹中读取WEB-INF文件夹外部的文件?
-conf
-image
-META-INF
-profiles
-WEB-INF
我想从文件夹“profiles”和“config”中读取一些文件。我试过使用
Properties prop = new Properties();
try{
prop.load(new FileInputStream("../webapps/WebApplicatioProject/profiles/file_001.properties"));
} catch (Exception e){
logger.error(e.getClass().getName());
}
它没有工作。然后我用
Properties prop = new Properties();
try{
prop.load(getClass().getResourceAsStream("../../../../profiles/fille_001.properties"));
} catch (Exception e){
logger.error(e.getClass().getName());
}
它也没有工作。
如何从WEB-INF文件夹以外的文件夹“profiles”和“conf”中读取文件?
不要把服务器文件的WEB-INF之外,因为用户可以简单地输入WEBCONTEXT/conf目录在浏览器中读取文件。 – Stefan