有关请求路径的总结 request.getContextPath()、request.getServletContext().getRealPath("")、request.getRequestURI

请求路径的URL http://localhost:8080/electest/system/elecMenuAction_menuHome.do

System.out.println("contentType------"+request.getContentType());
System.out.println("requestcontextPath------"+request.getContextPath());
System.out.println("servletPath----"+request.getServletPath());
System.out.println("requestRealPath"+request.getRealPath(""));
System.out.println("realPath------"+request.getServletContext().getRealPath(""));
System.out.println("requestURI------"+request.getRequestURI());
System.out.println("requestURL-------"+request.getRequestURL());
System.out.println("contextPath-------"+request.getServletContext().getContextPath());

打印结果

contentType------application/x-www-form-urlencoded
requestcontextPath------/electest
servletPath----/system/elecMenuAction_menuHome.do
requestRealPathD:\tomcate\apache-tomcat-7.0.63-windows-x64\apache-tomcat-7.0.63\webapps\electest
realPath------D:\tomcate\apache-tomcat-7.0.63-windows-x64\apache-tomcat-7.0.63\webapps\electest
requestURI------/electest/system/elecMenuAction_menuHome.do
requestURL-------http://localhost:8080/electest/system/elecMenuAction_menuHome.do
contextPath
---------/electest

你可能感兴趣的:(有关请求路径的总结 request.getContextPath()、request.getServletContext().getRealPath("")、request.getRequestURI)