Java获取tomcat中webapps路径

1.web项目中获得tomcat bin目录的路径,并获得webapps的路径
String path = System.getProperty("user.dir");//tomcat bin路径
path = path.substring(0,path.indexOf("bin"))+"webapps\\upload";
2.web项目中获得项目的跟路径,项目的绝对路径
String path2 = request.getSession().getServletContext().getRealPath("");//项目根路径

猜你喜欢

转载自blog.csdn.net/qq_32090861/article/details/80948667
今日推荐