读书人

web项目取得根路径在普通类中

发布时间: 2012-12-23 11:28:15 作者: rapoo

web项目,获得根路径,在普通类中

/**  * 得到WebRoot文件夹下的根路径,及web项目的根路径  * @return  */  public  String getWebRootAbsolutePath() {           String path = null;           String folderPath = Path.class.getProtectionDomain().getCodeSource()                   .getLocation().getPath();           if (folderPath.indexOf("WEB-INF") > 0) {               path = folderPath.substring(0, folderPath                       .indexOf("WEB-INF"));            }           return path;  }  

?

读书人网 >Web前端

热点推荐