在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():
/projectnamerequest.getContextPath():
/projectnamerequest.getRealPath():
/home/opt/apache-tomcat-8.5.5/webapps/projectname/