`
江雨行
  • 浏览: 23338 次
文章分类
社区版块
存档分类
最新评论

获取web应用根目录

 
阅读更多
public static 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/classes"));  
        }  
        return path;  
    }  

 

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics