初始Http协议的Delete和Put方法
个人文章现转到:http://onedear.cn/entry/http_delete_put_method.html 引用文章是:http://blog.csdn.net/kthq/archive/2010/01/08/5157822.aspx 同时提供w3c官方文档:http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html 扩展学习:http://www.infoq.com/cn/articles/designing-restful-http-apps-roth 听到人说http有delete、put等方法,立马查了资料,发现上述引用文章写得相当详细。就自己用文章的代码测试了一番。 [code="xml"] readonly false [/code] 在tomcat的web.xml的org.apache.catalina.servlets.DefaultServlet增加配置信息 [code="html"] test this is index.html
[/code] 首页index.html [code="js"] function getXMLHTTPRequest(){ if (XMLHttpRequest) { return new XMLHttpRequest(); } else { try{ return new ActiveXObject('Msxml2.XMLHTTP'); }catch(e){ return new ActiveXObject('Microsoft.XMLHTTP'); } } } var req = getXMLHTTPRequest(); function testDelete() { req.open('DELETE','http://localhost:8580/index.html',false); req.send(null); } [/code] httpMethod.js 启动tomcat,点击testDelete按钮,立刻把index.html删除了,看来直接请求资源删除是ok的。 如果请求servlet地址不是真实的资源uri会有什么效果呢? 继续测试