获取当前项目本地路径地址

//获取项目的本地路径
         String path = TestCtrl.class.getClassLoader().getResource("/").getPath(); String p = path.replaceAll("WEB-INF/.*", ""); System.out.println(path); System.out.println(p); /**********输出结果 /D:/tomcat-6.0.32/webapps/ROOT/WEB-INF/classes/ /D:/tomcat-6.0.32/webapps/ROOT/ ******/
原文地址:https://www.cnblogs.com/shell-blog/p/4745436.html