`
onedear
  • 浏览: 67999 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

初始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等方法,立马查了资料,发现上述引用文章写得相当详细。就自己用文章的代码测试了一番。
<init-param>    
   <param-name>readonly</param-name>    
   <param-value>false</param-value>   
</init-param>  

在tomcat的web.xml的org.apache.catalina.servlets.DefaultServlet增加配置信息

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test</title>
<script src="httpMethod.js"></script>
</head>
<body>
this is index.html
<br />
<input type="button" onclick="javascript:testDelete();" value = "testDelete"/>
</body>
</html>

首页index.html
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);  
}


httpMethod.js

启动tomcat,点击testDelete按钮,立刻把index.html删除了,看来直接请求资源删除是ok的。
如果请求servlet地址不是真实的资源uri会有什么效果呢?
继续测试
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics