标签:path example code 浏览器 打印 http 路径 div get
假定你的web application名称为example,你在浏览器中输入请求路径:
https://localhost:8080/example/main/edit.jsp
则执行下面代码后打印结果如下:
System.out.println(request.getContextPath()); //result:/example System.out.println(request.getServletPath()); //result:/main/edit.jsp
System.out.println(request.getRequestURI()); //result:/example/main/edit.jsp System.out.println(request.getRealPath("/")); //result:D:\Tomcat 7\webapps\example\test
getContextPath、getServletPath、getRequestURI的区别
标签:path example code 浏览器 打印 http 路径 div get
原文地址:http://www.cnblogs.com/donge92/p/6812169.html