得到项目的绝对路径

方法一:
String baseFolder = this.getServletConfig().getServletContext().getRealPath("/").replace("\\", "/");

方法二:
public String getRealPath(){
String folderPath=this.getClass().getClassLoader().getResource("").getPath();
String realPath = folderPath.substring(0, folderPath.indexOf("WEB-INF/classes"));
return realPath;
}

你可能感兴趣的:(绝对路径)