从request获取各种路径总结

从request获取各种路径总结
request.getRealPath("url");//虚拟目录映射为实际目录
request.getRealPath("./");//网页所在的目录
request.getRealPath("../");//网页所在目录的上一层目录

request.getContextPath();//应用的web目录的名称
   如http://localhost:7001/bookStore/ 
    /bookStore/      =>  [contextPath]  (request.getContextPath())

获取Web项目的全路径
String strDirPath = request.getSession().getServletContext().getRealPath("/");

你可能感兴趣的:(Web)