`

在普通Java类中获取项目在tomcat里面的物理路径

阅读更多
private String projectName="sz_pro";        //  你项目的名称

//获取当前项目的绝对路径
  public String getPorjectPath(){
   String nowpath;             //当前tomcat的bin目录的路径 如 D:\java\software\apache-tomcat-6.0.14\bin
   String tempdir;
   nowpath=System.getProperty("user.dir");
   tempdir=nowpath.replace("bin", "webapps");  //把bin 文件夹变到 webapps文件里面 
   tempdir+="\\"+projectName;  //拼成D:\java\software\apache-tomcat-6.0.14\webapps\sz_pro 
   return tempdir;  
  }

 

本文来自CSDN博客:http://blog.csdn.net/weiqingli190949353/archive/2009/12/17/5025662.aspx

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics