获取项目所在路径

/****取到 "http://localhost:8080/myProject/" ****/

 

String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";

 

 

/****取到 “D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/myProject/" ****/

 

String relativelyPath = request.getSession().getServletContext().getRealPath("/");

 

String relativelyPath = ServletActionContext.getServletContext().getRealPath("/"); //获取服务器根路径

你可能感兴趣的:(获取项目所在路径)