ITeye博客

获取web应用根目录

江雨行 · 2014-07-16 11:55 · 非技术 · Markdown

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;  
    }  

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。