private String getWebRoot() throws IllegalAccessException {
ProtectionDomain protectionDomain = getClass().getProtectionDomain();//getClass 是Object类的方法
String path = protectionDomain.getCodeSource().getLocation().getPath();
if (path.indexOf("WEB-INF") > 0) {
path = path.substring(0, path.indexOf("WEB-INF/classes"));
} else {
throw new IllegalAccessException("Fail to get WebRoot");
}
return path;
}
java获取WEB ROOT路径
精选 转载s_gjwu 博主文章分类:java web 服务端
文章标签 java获取WEB ROOT路径 文章分类 Java 后端开发
下一篇:EHCache 实例
-
java获取当月最大日
java获取当月最大日
System java 字段 -
获取当前web站点路径
[java] view plain copy//获取当前we站点的路径(在做上传下载的时候,可以
获取 web 站点 路径 下载