获得项目根目录及resource路径

//获得项目根路径

public String getBasePath(HttpServletRequest request) {
        return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
    }

//获得项目resource资源路径(一般配置文件及上传文件存放处)
    public String getRealPath(HttpServletRequest request){
        return request.getSession().getServletContext().getRealPath("/");
    }

你可能感兴趣的:(resource)