request.getRequestURI() 、request.getRequestURL() 、request.getContextPath()、request.getServletPath()区别
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()区别的更多相关文章
- getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
1 区别 假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 1.1 System.o ...
- Request中getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
1 区别 假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 1.1 System.o ...
- request.getRequestURL()和request.getRequestURI()的区别
request.getRequestURL() 返回全路径 request.getRequestURI() 返回除去host(域名或者ip)部分的路径 request.getContextPath() ...
- request.getRequestURI()与request.getRequestURL()
request.getRequestURL() 获得 http://www.quanqiuyouhui.com/ds-api-test/authorization/test.do request.ge ...
- getContextPath、getServletPath、getRequestURI、getRealPath、getRequestURL、getPathInfo();的区别
<% out.println("getContextPath: "+request.getContextPath()+"<br/>"); ou ...
- ${pageContext.request.contextPath}的解释以及和request.contextPath的区别
JSP中究竟采用绝对路径还是采用相对路径随着所采用技术的越来越复杂,这个问题也变得越来越难以解决. 1)采用相对路径遇到的问题 l 相对路径固然比较灵活,但如果想复制页面内的代码却变得比较困难,因为不 ...
- 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控制台 ...
- 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 ...
- request.getSession().setAttribute("",..)和request.setAttribute("",...)的差别
request.getSession.setAttribute()是获得当前会话的session,然后再setAttribute到session里面去,有效范围是session而不是request. ...
随机推荐
- Virtualbox安装Ubuntu
每次安装虚拟机都是总要折腾一下,毕竟不是特别熟悉,几个小细节总要google半天,为了以后能愉快的玩耍.把这些问题都记录下来,免得再折腾. 此文档都来自其他人的文章,我保存在Evernote整理. 网 ...
- Android 获得图片并解码成缩略图以减少内存消耗
本文内容 环境 演示 下载 Demo 环境 Windows 2008 R2 64 位 Eclipse ADT V22.6.2,Android 4.4.3 SAMSUNG GT-I9008L,Andro ...
- vcenter 5.1安装亲历
这一步死活提示nslookup 解析不了 ping的结果如下: 下载http://support.microsoft.com/kb/929852 工具 禁用IPv6即可,而且还需要在DNS中创建反向查 ...
- PetaPoco使用
<?xml version="1.0" encoding="utf-8" ?> <configuration> <connecti ...
- TQ2440开发板挂载U盘出现乱码
解决方法:配置内核 make menuconfig File Systems ---> DOS/FAT/NT Filesystems ---> (utf8) D ...
- SQL基础试题
第3章 关系数据库标准语言SQL 一.选择题 1.SQL语言是 的语言,易学习. A.过程化 B.非过程化 C.格式化 D.导航式 答案 ...
- QT Creator 环境使用 remote debug 调试 arm 程序
这里使用的 4.8.5 QTE 环境,之前尝试过远程使用 GDB 来调试板子上的 QT 程序,但是没成功.没有调试手段比较痛苦,今天又花了点时间,居然搞定了.粗做记录. 工具版本: 1. QtCrea ...
- Run Test Case on Spark
今天有哥们问到怎样对Spark进行单元測试.如今将Sbt的測试方法写出来,例如以下: 对Spark的test case进行測试的时候能够用sbt的test命令: 一.測试所有t ...
- 〖Linux〗Ubuntu中使用KVM安装虚拟机
1. 安装软件: sudo apt-get install libvirt0 libvirt-bin libvirt-dev virt-manager qemu-system 2. 配置网桥: # i ...
- excel快速访问工具栏和自定义选项卡
自定义选项卡: excel命令选项--自定义功能区--