java后台获取web项目全路径的方法: String basePath = request.getScheme()+"://" +request.getServerName()+":" +request.getServerPort()+ request.getContextPath() +"/"; eg: http://localhost:8080/first/