getRequestURI()就相当于你在写一个JSP页面的时候会有这样的东西"action='/WebRoot/xxx'"这个方法就是获得'/WebRoot/xxx',也就是说它会得到一个相对地址
而getRequestURL()会得到一个完整的URL地址,也就是绝对的绝对地址

Request.getRequestURL返回的是请求的全部,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数。
request.getRequestURI得到的是request URL的部分值,并且web容器没有decode过的

Java code

<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->getRequestURL:
public java.lang.StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append query parameters.

This method is useful for creating redirect messages and for reporting errors.

Returns:
a StringBuffer object containing the reconstructed URL

getRequestURI:
public java.lang.String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example:
First line of HTTP request Returned Value
POST /some/path.html HTTP/1.1 /some/path.html
GET http://foo.bar/a.html HTTP/1.0 /a.html
HEAD /xyz?a=b HTTP/1.1 /xyz
To reconstruct an URL with a scheme and host, use HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest).
Returns:
a String containing the part of the URL from the protocol name up to the query string
See Also:
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)

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.getRequestURL的更多相关文章

  1. request.getRequestURI()与request.getRequestURL()

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

  2. request.getRequestURI() 、request.getRequestURL() 、request.getContextPath()、request.getServletPath()区别

    request.getRequestURI() /jqueryWeb/resources/request.jsprequest.getRequestURL() http://localhost:808 ...

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

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

  4. request 对象和 response 对象

    Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象.和代表响应的response对象 HttpServletResponse HttpServletR ...

  5. Request 和 Response 原理

    * Request 和 Response 原理:     * request对象和response对象由服务器创建,我们只需要在service方法中使用这两个对象即可        * 继承体系结构: ...

  6. (转)Nginx SSL+tomcat集群,request.getScheme() 取到https正确的协议

    转自http://www.cnblogs.com/interdrp/p/4881785.html 最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,to ...

  7. javaWeb中 servlet 、request 、response

    1.Servlet (1)Servlet是JavaEE的一个动态web资源开发技 术,就是在服务器上运行的小程序,这个小程序是由服务器调用的,服务器为了能调用这个小程序,就要求这样的程序必须实现一个S ...

  8. jsp Request获取url信息的各种方法比较

    从Request对象中可以获取各种路径信息,以下例子: 假设请求的页面是index.jsp,项目是WebDemo,则在index.jsp中获取有关request对象的各种路径信息如下 String p ...

  9. Request中的各种方法

    前言 Request中方法众多,对于Java Web程序员来说,种种方法都会在工作中常常用到.Request由于不是JDK的一部分,这些方法的用法也没有专门的API可以查,所以在工作中遇到Reques ...

随机推荐

  1. 网络打印协议之LPR或RAW

    网络打印端口 标准 TCP/IP 端口监视器 对于连接到网络的打印设备,标准的 TCP/IP 端口监视器就是最佳选择.标准端口监视器增强了LPR(line printer remote,远程行式打印机 ...

  2. java执行jar包

    一般运行包含manifest的jar包,可以使用 java -jar <jar-file-name>.jar 如果jar里没有 manifest,则可以使用 java -cp foo.ja ...

  3. MySQL和Redis面试题小结

    MySQL专题 1. 主键 超键 候选键 外键 主 键: 数据库表中对储存数据对象予以唯一和完整标识的数据列或属性的组合.一个数据列只能有一个主键,且主键的取值不能缺失,即不能为空值(Null). 超 ...

  4. 监控http服务脚本

    [root@ob1 scripts]# vim test_httpd.sh 1 #!/bin/bash 2 #ss -tlnup|grep :80 >/dev/null 2>&1 ...

  5. ASP.NET MVC 使用 Datatables (2)

    在服务器端实现分页,排序,获取当前页面数据 在上篇的基础上进行改造(datatables的客户端实现) 1.修改View页面代码如下: <div class="row"> ...

  6. [oracle] 系统权限管理

    1 利用超级用户连接到数据库登录 sqlplus / as sysdba or slqplus SYS/SYSPWD as sysdba 这两个命令的效果是一样的,都是以sysdba的身份使得SYS管 ...

  7. 关于Cocos2d-x中根据分数增加游戏难度的方法

    1.GameScene.h中声明一些分数边界值 //level提升所需的分数 enum LevelUp_Score { Level1Up_Score = , Level2Up_Score = , Le ...

  8. 【转】C# 调用WebService的方法

    很少用C#动态的去调用Web Service,一般都是通过添加引用的方式,这样的话是自动成了代理,那么动态代理调用就是我们通过代码去调用这个WSDL,然后自己去生成客户端代理.更多的内容可以看下面的两 ...

  9. DirectoryEntry 账户启动与停用 以及创建账户等

    启动账户: DirectoryEntry usr = new DirectoryEntry("LDAP://CN=New User,CN=users,DC=fabrikam,DC=com&q ...

  10. CentOS系统命令

    系统命令 yum命令 yum makecache yum 生成缓存 yum list installed mysql* 查看有没有安装过*包 rpm -qa | grep mysql* 查看有没有安装 ...