Request.getRequestURL
getRequestURI()就相当于你在写一个JSP页面的时候会有这样的东西"action='/WebRoot/xxx'"这个方法就是获得'/WebRoot/xxx',也就是说它会得到一个相对地址
而getRequestURL()会得到一个完整的URL地址,也就是绝对的绝对地址
Request.getRequestURL返回的是请求的全部,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数。
request.getRequestURI得到的是request URL的部分值,并且web容器没有decode过的
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的更多相关文章
- request.getRequestURI()与request.getRequestURL()
request.getRequestURL() 获得 http://www.quanqiuyouhui.com/ds-api-test/authorization/test.do request.ge ...
- request.getRequestURI() 、request.getRequestURL() 、request.getContextPath()、request.getServletPath()区别
request.getRequestURI() /jqueryWeb/resources/request.jsprequest.getRequestURL() http://localhost:808 ...
- request.getRequestURL()和request.getRequestURI()的区别
request.getRequestURL() 返回全路径 request.getRequestURI() 返回除去host(域名或者ip)部分的路径 request.getContextPath() ...
- request 对象和 response 对象
Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象.和代表响应的response对象 HttpServletResponse HttpServletR ...
- Request 和 Response 原理
* Request 和 Response 原理: * request对象和response对象由服务器创建,我们只需要在service方法中使用这两个对象即可 * 继承体系结构: ...
- (转)Nginx SSL+tomcat集群,request.getScheme() 取到https正确的协议
转自http://www.cnblogs.com/interdrp/p/4881785.html 最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,to ...
- javaWeb中 servlet 、request 、response
1.Servlet (1)Servlet是JavaEE的一个动态web资源开发技 术,就是在服务器上运行的小程序,这个小程序是由服务器调用的,服务器为了能调用这个小程序,就要求这样的程序必须实现一个S ...
- jsp Request获取url信息的各种方法比较
从Request对象中可以获取各种路径信息,以下例子: 假设请求的页面是index.jsp,项目是WebDemo,则在index.jsp中获取有关request对象的各种路径信息如下 String p ...
- Request中的各种方法
前言 Request中方法众多,对于Java Web程序员来说,种种方法都会在工作中常常用到.Request由于不是JDK的一部分,这些方法的用法也没有专门的API可以查,所以在工作中遇到Reques ...
随机推荐
- C++ 递归实现汉诺塔
C++实现汉诺塔 #include <iostream> using namespace std; void move(int n,char x,char y,char z) { ) { ...
- jsp页面积累
out.print(页面html);response.setContexttype("");以页面的形式展现java
- 关于Cocos2d-x的瓦片地图
1.cocos2d-x的瓦片地图是用Tiled地图编辑器做的,这个软件开源,免费,一般都是用它制作瓦片地图. 2.瓦片地图是由块层和对象组成的,块层的作用是显示和一些重叠的时候覆盖角色的作用,而对象是 ...
- python中的高阶函数
高阶函数英文叫Higher-order function.什么是高阶函数?我们以实际代码为例子,一步一步深入概念. 变量可以指向函数 以Python内置的求绝对值的函数abs()为例,调用该函数用以下 ...
- sendEvent()
sendEvent()(QObject *receiver, QEvent *event)可以将自己创建事件event发送给制定的receiver 例如, //创建按键事件 QKeyEvent key ...
- Spring @ControllerAdvice @ExceptionHandler
先来两个连接: Spring3.2新注解@ControllerAdvice Spring 注解学习手札(八)补遗——@ExceptionHandler @Controller Class中如果有@Ex ...
- 利用CMake和OpenCV源代码生成Visual Studio工程
OpenCV1.0版本有windows,linux之分,笔者曾经一直使用Opencv1.0.这个版本在下载,安装之后,在 \OpenCV\_make文件夹下面已经存在了一个opencv.dsw的工程文 ...
- 解决ERROR_INVALID_USER_BUFFER
我用CSocket编写了一个HTTP下载程序,接收数据大概如下: //...... //use CSocket class //send request... //...... ); ) { Zero ...
- 转载:【原译】Erlang构建和匹配二进制数据(Efficiency Guide)
转自:http://www.cnblogs.com/futuredo/archive/2012/10/19/2727204.html Constructing and matching binarie ...
- 【JavaNIO的深入研究4】内存映射文件I/O,大文件读写操作,Java nio之MappedByteBuffer,高效文件/内存映射
内存映射文件能让你创建和修改那些因为太大而无法放入内存的文件.有了内存映射文件,你就可以认为文件已经全部读进了内存,然后把它当成一个非常大的数组来访问.这种解决办法能大大简化修改文件的代码.fileC ...