具体获取方式:
/**
*
* @return WebRoot目录的绝对路径
*/
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;
}