String nodepath = this.getClass().getClassLoader().getResource("/").getPath();
// 项目的根目录路径
String filePath = nodepath.substring(1, nodepath.length() - 16);
注意:这里每个文件夹中的名字不能有空格,不然会报错
获取tomcat下java项目根目录路径
最新推荐文章于 2022-07-09 15:11:10 发布