当前位置: 代码迷 >> Web前端 >> http 的四慷慨式
  详细解决方案

http 的四慷慨式

热度:106   发布时间:2013-08-04 18:26:16.0
http 的四大方式
有get,post,delete,put.

其中delete,put在tomcat 里模式不支持,需要在web.xml里

引用
<init-param>   
    <param-name>readonly</param-name>   
    <param-value>false</param-value>  
</init-param>



?接下来,从客户端通过 Ajax XMLHTTPRequest 发起 DELETE/PUT 请求:
引用
[javascript] view plaincopyprint?
01.function getXMLHTTPRequest(){ 
02.    if (XMLHttpRequest)    { 
03.        return new XMLHttpRequest(); 
04.    } else { 
05.        try{ 
06.            return new ActiveXObject('Msxml2.XMLHTTP'); 
07.        }catch(e){ 
08.            return new ActiveXObject('Microsoft.XMLHTTP'); 
09.        } 
10.    } 
11.} 
12.var req = getXMLHTTPRequest(); 
13.req.open('DELETE','http://localhost/test.jsp',false); 
14.req.send(null); 
15.document.write(req.responseText); 
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请求方法。
  相关解决方案