java 得到项目的根目录的绝对路径
public static String getPath(HttpServletRequest request){
String sysPath = request.getServletContext().getRealPath("/");
sysPath = sysPath.replaceAll("\\\\", "/");
String[] str=sysPath.split("/");
StringBuffer sb =new StringBuffer();
for(int i = 0; i < str.length-1;i++){
sb.append(str[i]+"/");
}
return sb.toString();
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-8521.html