request.getRequestURI() /jqueryWeb/resources/request.jsp
request.getRequestURL() http://localhost:8080/jqueryWeb/resources/request.jsp
request.getContextPath()/jqueryWeb
request.getServletPath()/resources/request.jsp

注: resources为WebContext下的目录名
jqueryWeb 为工程名

-----------------------------------------------------
<%=request.getRequestURI() %><br/>
<%=request.getRequestURL() %><br/>
<%=request.getContextPath()%><br/>
<%=request.getServletPath() %><br/>
<%=request.getPathInfo() %><br/>
结果:
/test-struts.jsp
http://127.0.0.1:8080/test-struts.jsp

/test-struts.jsp
null

配置:
<action name="test" class="testStrutsAction" method="test"> 
   <result>/test-struts.jsp</result>
</action>

假定你的web application 名称为news,你在浏览器中输入请求路径:

http://localhost:8080/news/main/list.jsp

则执行下面向行代码后打印出如下结果:

1、 System.out.println(request.getContextPath());

打印结果:/news

2、System.out.println(request.getServletPath());

打印结果:/main/list.JSP

3、 System.out.println(request.getRequestURI());

打印结果:/news/main/list.JSp

4、 System.out.println(request.getRealPath("/"));

打印结果:F:\tomcat 6.0\webapps\news\test

request.getRequestURI() 、request.getRequestURL() 、request.getContextPath()、request.getServletPath()区别的更多相关文章

  1. getContextPath、getServletPath、getRequestURI、request.getRealPath的区别

    1 区别 假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 1.1 System.o ...

  2. Request中getContextPath、getServletPath、getRequestURI、request.getRealPath的区别

    1 区别 假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 1.1 System.o ...

  3. request.getRequestURL()和request.getRequestURI()的区别

    request.getRequestURL() 返回全路径 request.getRequestURI() 返回除去host(域名或者ip)部分的路径 request.getContextPath() ...

  4. request.getRequestURI()与request.getRequestURL()

    request.getRequestURL() 获得 http://www.quanqiuyouhui.com/ds-api-test/authorization/test.do request.ge ...

  5. getContextPath、getServletPath、getRequestURI、getRealPath、getRequestURL、getPathInfo();的区别

    <% out.println("getContextPath: "+request.getContextPath()+"<br/>"); ou ...

  6. ${pageContext.request.contextPath}的解释以及和request.contextPath的区别

    JSP中究竟采用绝对路径还是采用相对路径随着所采用技术的越来越复杂,这个问题也变得越来越难以解决. 1)采用相对路径遇到的问题 l 相对路径固然比较灵活,但如果想复制页面内的代码却变得比较困难,因为不 ...

  7. Spring boot: Request method 'DELETE' not supported, Request method 'PUT' not supported, Request method 'POST' not supported

    GET,POST,PUT,DELETE, Spring都支持,不要怀疑Spring, 一定是前端发送的rest 请求和后端的响应不匹配, 查找原因以及解决办法, 很简单 用chrome打开F12控制台 ...

  8. AWS CloudFront CDN直接全站加速折腾记The request could not be satisfied. Bad request

    ERROR The request could not be satisfied. Bad request. Generated by cloudfront (CloudFront) Request ...

  9. request.getSession().setAttribute(&quot;&quot;,..)和request.setAttribute(&quot;&quot;,...)的差别

    request.getSession.setAttribute()是获得当前会话的session,然后再setAttribute到session里面去,有效范围是session而不是request. ...

随机推荐

  1. 用 CSS 实现元素垂直居中,有哪些好的方案?

    1.不知道自己高度和父容器高度的情况下, 利用绝对定位只需要以下三行: parentElement{ position:relative; } childElement{ position: abso ...

  2. Android Studio:xxx is not an enclosing class 错误的解决方法

    Android Studio:xxx is not an enclosing class 错误的解决方法 这个问题一般出现在内部类中,若要创建内部类的实例,需要有外部类的实例才行,或者是将内部类设置为 ...

  3. SpringMVC验证框架Validation特殊用法

    基本用法不说了,网上例子很多,这里主要介绍下比较特殊情况下使用的方法. 1. 分组 有的时候,我们对一个实体类需要有多中验证方式,在不同的情况下使用不同验证方式,比如说对于一个实体类来的id来说,保存 ...

  4. C#.NET常见问题(FAQ)-如何使用变量访问控件属性

    不管哪种类型的控件,可以用下面这种强制转换和Controls.Find的方法来读写控件的属性 //我在界面上做了三个picturebox控件 PictureBox p; //注意索引必须从1开始,并且 ...

  5. 造轮子 | 怎样设计一个面向协议的 iOS 网络请求库

    近期开源了一个面向协议设计的网络请求库 MBNetwork,基于 Alamofire 和 ObjectMapper 实现,目的是简化业务层的网络请求操作. 须要干些啥 对于大部分 App 而言,业务层 ...

  6. All you should know about NUMA in VMware!

    http://www.elasticvision.info/ All you should know about NUMA in VMware! Lets try answering some typ ...

  7. NUMA总结。

    vsphere 5.1性能最佳实践http://www.vmware.com/pdf/Perf_Best_Practices_vSphere5.1.pdf vNUMA 要求:硬件版本8以上. 1.整个 ...

  8. Python2.7.14新手学习

    python2.7.14 让用户选择一个功能,然后对其进行操作的例子.中间有问题的是年龄没有做是否是数字判断 注意:和版本python3不同的地方 1.编码 2.输入地方是raw_input 3.业务 ...

  9. SpringBoot引入freemaker前端模板

    1.引入freeMarker的依赖包 <!-- 引入freeMarker的依赖包. --> <dependency> <groupId>org.springfram ...

  10. java 生成GUID与UUID

      java 生成GUID与UUID CreateTime--2018年5月31日16点29分 Author:Marydon import java.util.UUID; public static ...