- 浏览: 226585 次
- 性别:
- 来自: 汨罗
文章分类
最新评论
-
tssinbc:
jpos-1.4.4.zip 这个包内容这么多,怎么使用啊,
JPos 学习 -
ruyi0127:
很棒, 棒我忙了
JQuery 弹出层,始终显示在屏幕正中间 -
csdxzsky:
好分享,谢谢
JPos 学习 -
lijunwyf41:
写的不错,期待更多的示例
JPos 学习 -
在世界的中心呼喚愛:
spp_1987 写道这个遮挡层不错 , 但是为什么取消这个遮 ...
JQuery 遮罩层
原文出自:http://blog.csdn.net/kthq/article/details/5157822#
一般来说,Web服务器默认的只支持Post和Get这两种“只读”的请求方法。但是随着Ajax XMLHttpRequest 和 REST风格应用的深入,我们发现Http 1.1协议还支持如下请求方法(Request Method):
-
OPTIONS
-
HEAD
-
DELETE
-
PUT
-
TRACE
-
CONNECT
Get是最常用的,就是向Web Server发请求“获取”资源;那么Post就是向Web Server“邮寄”一些封装的数据包获取资源,这两者方法严格的说都是“索取”行为。
顾名思义,Delete方法就是通过http请求删除指定的URL上的资源啦,Delete请求一般会返回3种状态码:
- 200 (OK) - 删除成功,同时返回已经删除的资源
- 202 (Accepted) - 删除请求已经接受,但没有被立即执行(资源也许已经被转移到了待删除区域)
- 204 (No Content) - 删除请求已经被执行,但是没有返回资源(也许是请求删除不存在的资源造成的)
Put方法就不多废话了,就是往Web Server上直接扔资源(上传资源)嘛,不过实际操作起来可能会让诸位看官喝一壶,E文定义如下:
The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request. If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.
If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.
The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI,
it MUST send a 301 (Moved Permanently) response; the user agent MAY then make its own decision regarding whether or not to redirect the request.
A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying "the current version" which is separate from the URI identifying each particular version. In this case, a PUT request on a general URI might result in several other URIs being defined by the origin server.
HTTP/1.1 does not define how a PUT method affects the state of an origin server.
PUT requests MUST obey the message transmission requirements set out in section 8.2.
Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied to the resource created or modified by the PUT.
上面说的都是虚的,实战才是硬道理!
- 首先,我们要让Web Server支持Delete 和 Put请求方法,以大家熟悉的Tomcat为例:
在Tomcat的web.xml 文件中配置 org.apache.catalina.servlets.DefaultServlet 的初始化参数
一般来说,Web服务器默认的只支持Post和Get这两种“只读”的请求方法。但是随着Ajax XMLHttpRequest 和 REST风格应用的深入,我们发现Http 1.1协议还支持如下请求方法(Request Method):
-
OPTIONS
-
HEAD
-
DELETE
-
PUT
-
TRACE
-
CONNECT
Get是最常用的,就是向Web Server发请求“获取”资源;那么Post就是向Web Server“邮寄”一些封装的数据包获取资源,这两者方法严格的说都是“索取”行为。
顾名思义,Delete方法就是通过http请求删除指定的URL上的资源啦,Delete请求一般会返回3种状态码:
- 200 (OK) - 删除成功,同时返回已经删除的资源
- 202 (Accepted) - 删除请求已经接受,但没有被立即执行(资源也许已经被转移到了待删除区域)
- 204 (No Content) - 删除请求已经被执行,但是没有返回资源(也许是请求删除不存在的资源造成的)
Put方法就不多废话了,就是往Web Server上直接扔资源(上传资源)嘛,不过实际操作起来可能会让诸位看官喝一壶,E文定义如下:
The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request. If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.
If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.
The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI,
it MUST send a 301 (Moved Permanently) response; the user agent MAY then make its own decision regarding whether or not to redirect the request.
A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying "the current version" which is separate from the URI identifying each particular version. In this case, a PUT request on a general URI might result in several other URIs being defined by the origin server.
HTTP/1.1 does not define how a PUT method affects the state of an origin server.
PUT requests MUST obey the message transmission requirements set out in section 8.2.
Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied to the resource created or modified by the PUT.
上面说的都是虚的,实战才是硬道理!
- 首先,我们要让Web Server支持Delete 和 Put请求方法,以大家熟悉的Tomcat为例:
在Tomcat的web.xml 文件中配置 org.apache.catalina.servlets.DefaultServlet 的初始化参数
<init-param> <param-name>readonly</param-name> <param-value>false</param-value> </init-param>
readonly参数默认是true,即不允许delete和put操作,所以默认的通过XMLHttpRequest对象的put或者delete方法访问就会报告 http 403 forbidden 错误。
接下来,从客户端通过 Ajax XMLHTTPRequest 发起 DELETE/PUT 请求:
function getXMLHTTPRequest(){ if (XMLHttpRequest) { return new XMLHttpRequest(); } else { try{ return new ActiveXObject('Msxml2.XMLHTTP'); }catch(e){ return new ActiveXObject('Microsoft.XMLHTTP'); } } } var req = getXMLHTTPRequest(); req.open('DELETE','http://localhost/test.jsp',false); req.send(null); document.write(req.responseText);
WebDAV也需要使用到这2种Http请求方法。
发表评论
-
利用Axis编写简单的WebService
2012-08-29 16:28 1758原文出自:http://nopainnogain.iteye. ... -
java cookie跨域操作
2012-08-13 10:14 1301原文出自:http://hi.baidu.com/feixia ... -
顺序读取属性文件
2012-07-13 17:14 1645不多说,直接上代码 import java.io.Buffe ... -
采用jacob读取并在网页中显示ppt、word、excel .
2012-05-02 16:48 1163原文出自:http://blog.csdn.net/chrys ... -
伪造 referer
2012-05-02 14:53 1247HttpURLConnection conn = (HttpU ... -
深入理解HTTP协议(转) .
2012-04-28 17:30 938原文出自:http://blog.csdn.net/lxzo1 ... -
SpringMVC3
2012-04-23 13:41 933原文出自:http://blog.csdn.net/sunit ... -
400 500 503错误的配置
2012-04-20 15:23 1645最近工作中,社区为了提高用户感受,对三种异常(404/500/ ... -
Spring JDBCTemplate
2012-04-17 17:34 903原文出自:http://www.blogjava.net/wy ... -
用Spring让JavaMail支持简化邮件发送
2012-04-16 17:36 981原文出自:http://www.examw.com/java/ ... -
Cache-control使用:header('Cache-control:private')
2012-04-16 10:46 2669Cache-control使用:header('Cach ... -
JAVA远程调用
2012-04-13 17:10 929原文出自:http://www.iteye.com/topic ... -
清除 Struts1.x的 ActionFrom
2012-03-15 11:26 1100一个updateAction 一个addAction ... -
JavaServerWrapper做成服务
2011-12-06 17:14 1122JavaServerWrapper出现的原因: ... -
2个Integer作比较时,需要注意的地方
2011-03-09 17:17 1103今天受打击了,一同事问了我一个问题,,,我当场就肯定的说:答案 ... -
浅谈内部类与静态内部类的应用
2011-03-03 18:00 1824起因:我在看LinkedList源码的时候,发现他用的辅助类是 ... -
ArrayList
2011-02-15 14:19 1373ArrayList学习心得: 看完ArrayList后 ...
相关推荐
一般来说,Web服务器默认的只支持Post和Get...但是随着Ajax XMLHttpRequest 和 REST风格应用的深入,我们发现Http 1.1协议还支持如下请求方法(Request Method): •OPTIONS •HEAD •DELETE •PUT •TRACE •CONNECT
在这个服务中,提到了四个主要的HTTP方法:POST、DELETE、PUT和GET,这些方法分别对应于创建、删除、更新和查询资源的操作。 1. **POST** 方法:在RESTful API中,POST方法常用于创建新的资源。客户端发送一个POST...
在本文中,我们将深入探讨如何使用VC++实现HTTP的基本操作,包括POST、GET、PUT和DELETE,以及如何处理代理设置、读取HTTP头信息和解析HTML文档中的特定标签属性值。这些功能对于开发RESTful API客户端或者进行网络...
HTTP 方法详解 在 HTTP 中,定义了多种方法来与服务器进行交互,...HTTP 方法是 HTTP 协议的核心部分,每种方法都有其特定的用途和限制。了解每种方法的用途和限制对于开发者来说非常重要,以便更好地使用 HTTP 协议。
本文将深入探讨一个通用的HTTP接口调试工具,该工具支持GET、POST、PUT、PATCH和DELETE等常见HTTP请求方法,并且专注于处理JSON格式的数据。这将帮助开发者在开发和测试过程中更加高效地进行接口调用与验证。 首先...
本篇将详细解释如何使用Java发送PUT、DELETE、POST和GET这四种主要的HTTP请求。 PUT请求常用于更新已有资源,它的特点是替换目标URL指定的整个资源。在Java中,可以使用HttpURLConnection或Apache HttpClient库来...
本教程将详细介绍如何在UniApp中封装request网络请求,包括GET、POST、PUT和DELETE四种常见的HTTP方法。 首先,我们需要了解HTTP协议中的这四种方法: 1. GET:获取资源,是最常用的方法,用于从服务器上获取特定的...
PUT方法用于更新已有资源,其行为类似于替换,即用请求主体中的数据完全替换掉服务器上指定URL的资源。DELETE方法则请求服务器删除指定的资源,但HTTP规范允许服务器在不告知客户端的情况下取消删除请求。 HEAD方法...
例如,PUT和DELETE方法可以被用于修改或删除服务器上的资源,而TRACE方法则有可能泄露敏感信息。 #### 安全风险分析 1. **PUT和DELETE方法**:若服务器启用了这两个方法,恶意用户可能会利用它们来修改或删除服务器...
HTTP中的POST和GET方法是两种最常用于网页开发的数据传输方式,它们在原理和表现形式上存在本质区别。 首先,从原理上看,GET方法通常用于获取资源信息,它通过URL来传递参数,URL全称为资源描述符,表示网络上的一...
HTTP 请求方法包括 GET、POST、HEAD、PUT、DELETE、TRACE、CONNECT、OPTIONS 等。每种方法规定了客户与服务器联系的类型不同。 GET 方法:请求获取 Request-URI 所标识的资源。 POST 方法:请求服务器接受附在请求...
2. HTTP方法:HTTP定义了多种请求方法,常见的有GET(获取资源)、POST(提交数据)、PUT(更新资源)、DELETE(删除资源)等。GET是最常用的方法,用于获取服务器上的资源;POST常用于提交表单数据,创建新的资源。...
HTTP/1.1是HTTP协议的一个重要版本,相比之前的HTTP/1.0,它引入了许多改进和新特性,如持久连接、分块传输编码和更多请求方法(如PUT、DELETE)。 **HTTP请求方法** HTTP协议定义了多种请求方法,常见的有GET、...
2. **请求方法**:详述GET、POST、PUT、DELETE等方法的含义和使用场景,以及HEAD、OPTIONS、PATCH等其他方法。 3. **请求头**:请求头包含了许多关键信息,如User-Agent表示客户端信息,Accept表示客户端可接受的...
HTTP PUT方法是HTTP协议中的一种请求方法,用于向服务器上传或更新指定资源。在Web服务和API设计中,PUT通常用于替换已存在的资源,而不仅仅是添加新内容。这个压缩包文件包含了关于如何在Java中使用...
除此之外,还有PUT、DELETE、HEAD等其他方法,它们各自在不同的场景下有着特定的应用。 HTTP请求报文由三部分组成:请求行、请求头部和请求主体。请求行包含了方法、URL和HTTP版本信息,例如"GET /index....
1. 请求方法:常见的HTTP请求方法有GET、POST、PUT、DELETE等,每个方法对应不同的资源操作。 2. URL(统一资源定位符):用于标识网络上的唯一资源,包括协议类型、主机名、端口号和路径。 3. 头部字段:HTTP请求和...
总结来说,"张孝祥_HTTP协议详解第四讲"深入浅出地讲解了HTTP协议的关键要素,包括其工作原理、请求响应流程、请求方法、版本差异、状态码、安全性和缓存机制。通过这堂课的学习,我们可以更好地理解和应用HTTP协议...
2. **CRUD操作**: 使用HTTP方法对应资源的操作,GET获取资源,POST创建资源,PUT更新资源,DELETE删除资源。 3. **状态码反馈**: 通过状态码告知客户端操作结果,如201表示资源已创建,204表示无内容。 ### 总结 ...