标签:服务 static pat sub session bpa res dex request
获得WebRoot的路径:
request.getSession().getServletContext().getRealPath("/");
获得class的路径:
this.getClass().getClassLoader().getResource("").getPath();
获取服务器上WEBAPPS路径
public static String getRealWebappsPath(HttpServletRequest request) { String webPath = request.getSession().getServletContext().getRealPath( "/"); String basePath = webPath.substring(0, webPath.indexOf(request .getContextPath().substring(1))); return basePath; }
标签:服务 static pat sub session bpa res dex request
原文地址:https://www.cnblogs.com/qyy1207/p/10209754.html