java上传到tomcat路径_从Java到Tomcat路径的访问

我有一个在本地Tomcat中运行的webapp。路径是:tomcat/webapps/myproject。

我在这个项目中有一些资源,都在以下路径的文件夹中:tomcat/webapps/myproject/resources

因此,我正在尝试使用file来访问Java项目中的这些资源config.properties。在这个文件中,我有这样的东西:

tomcat.url= http://localhost

tomcat.port=8080

tomcat.resources=/myproject/resources

我也尝试了/或的不同组合,\但在运行项目时遇到此错误:

Trying to acces to a directory that does not exist

我的Java代码:

Configuration config = new PropertiesConfiguration("config.properties");

String sourcePath = config.getString("tomcat.resources");

//And I try to list this folder

File dir = new File(sourcePath);

String[] children = dir.list();

if (children == null) {

// Either dir does not exist or is not a directory

throw new ServiceExecutionException("Trying to generate Metadata in a directory that does not exist");

}

我不知道出什么问题了,在我之前做过的项目中,与此类似,我有类似的东西,它找到了一切。

有任何想法吗??提前致谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值