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

猜你喜欢

转载自yuxinglab.iteye.com/blog/2092691
今日推荐