首页 > 其他 > 详细

获取路径

时间:2019-01-02 18:26:04      阅读:139      评论:0      收藏:0      [点我收藏+]

获得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;
}

 

获取路径

原文:https://www.cnblogs.com/qyy1207/p/10209754.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!