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

 

你可能感兴趣的:(Web应用)