linux下Servlet中各种Path的值

在linux中tomcat下打印项目HttpServletRequest的值,如下:

System.out.println("request.getServletContext().getRealPath :" + request.getServletContext().getRealPath(""));

System.out.println("request.getServletContext().getContextPath():" + request.getServletContext().getContextPath());

System.out.println("request.getContextPath():" + request.getContextPath());

System.out.println("request.getRealPath():" + request.getRealPath(""));

request.getServletContext().getRealPath:
/home/opt/apache-tomcat-8.5.5/webapps/projectname/

request.getServletContext().getContextPath():
/projectname

request.getContextPath():
/projectname

request.getRealPath():
/home/opt/apache-tomcat-8.5.5/webapps/projectname/

猜你喜欢

转载自blog.csdn.net/jianiuqi/article/details/53894029