jsp发布后应用根目录

1.发布到tomcat后获取应用的根目录

 

 ServletContext s1=this.getServletContext();

String temp=s1.getRealPath("/");//C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\demo1\
String temp=s1.getRealPath("/WEB-INF/classes/log4j.properties"); //C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\demo1\WEB-INF\classes\log4j.properties

posted @ 2016-11-06 19:21  甜菜波波  阅读(270)  评论(0编辑  收藏  举报