91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

是一個Java 發送http put、delete、 post、 get 請求的工具類。可用在與restful service 進行通訊的代碼中。

資源截圖

代碼片段和文件信息

package?com.ganji.as.restful.service.spi.intf;

import?java.io.IOException;
import?java.io.UnsupportedEncodingException;
import?java.util.ArrayList;
import?java.util.List;
import?java.util.Map;

import?org.apache.commons.logging.Log;
import?org.apache.commons.logging.LogFactory;
import?org.apache.http.HttpResponse;
import?org.apache.http.HttpStatus;
import?org.apache.http.client.HttpClient;
import?org.apache.http.client.entity.UrlEncodedFormEntity;
import?org.apache.http.client.methods.HttpDelete;
import?org.apache.http.client.methods.HttpPut;
import?org.apache.http.impl.client.DefaultHttpClient;
import?org.apache.http.message.BasicNameValuePair;
import?org.apache.http.protocol.HTTP;
import?org.apache.http.util.EntityUtils;

import?com.ganji.common.utils.HttpUtil;

/***
?*?
?*?@author?yikangfeng
?*
?*/
class?RestfulRequestHelper?extends?HttpUtil?{
static?private?final?Log?LOG?=?LogFactory
.getLog(RestfulRequestHelper.class);

static?public?String?sendPOST(String?restfulUrl?Map?params)?{
return?doPost(restfulUrl?params);
}

static?public?String?sendDELETE(String?restfulUrl
Map?params)?{
HttpClient?client?=?new?DefaultHttpClient();
HttpDelete?requestDelete?=?new?HttpDelete(restfulUrl);
requestDelete
.setHeader(“Accept“
“application/json?application/xml?text/html?text/*?image/*?*/*“);
String?result?=?““;
try?{
HttpResponse?httpResponse?=?client.execute(requestDelete);
if?(httpResponse?==?null)
return?result;
if?(httpResponse.getStatusLine().getStatusCode()?==?HttpStatus.SC_OK)
result?=?EntityUtils.toString(httpResponse.getEntity());
}?catch?(IOException?ignore)?{
ignore.printStackTrace();
if?(LOG.isErrorEnabled())
LOG.error(ignore);
}?finally?{
if?(client?!=?null)
client

評論

共有 條評論