---
title: "http 的四大方式"
author: "dmwdmc"
date: "2013-07-24T11:33:16Z"
tags: []
categories: ["Web前端"]
slug: "http"
draft: false
lastmod: "2013-07-24T11:33:16Z"
id: 1912577
url: "https://dmwdmc.iteye.com/blog/1912577"
---

有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请求方法。