public String getWebContentPath(String projiectName){
String path=Thread.currentThread().getContextClassLoader().getResource("").getPath();
System.out.println(path);
int num = path.indexOf(".metadata");
String webContentPath = path.substring(1,num).replace('/', '\\')+projiectName+"\\WebContent\\";
return webContentPath;
}
获取根路径
获取WebContent路径方法
本文介绍了一种在Java中获取指定项目的WebContent目录路径的方法。该方法通过当前线程上下文类加载器获取资源路径,并对其进行字符串操作来提取所需的WebContent路径。

被折叠的 条评论
为什么被折叠?



