當前位置: 首頁>>代碼示例>>Java>>正文


Java PostMethod.addParameters方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.methods.PostMethod.addParameters方法的典型用法代碼示例。如果您正苦於以下問題:Java PostMethod.addParameters方法的具體用法?Java PostMethod.addParameters怎麽用?Java PostMethod.addParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.methods.PostMethod的用法示例。


在下文中一共展示了PostMethod.addParameters方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: httpClientPost

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
public static final String httpClientPost(String url, ArrayList<NameValuePair> list) {
    String result = "";
    HttpClient client = new HttpClient();
    PostMethod postMethod = new PostMethod(url);
    try {
        NameValuePair[] params = new NameValuePair[list.size()];
        for (int i = 0; i < list.size(); i++) {
            params[i] = list.get(i);
        }
        postMethod.addParameters(params);
        client.executeMethod(postMethod);
        result = postMethod.getResponseBodyAsString();
    } catch (Exception e) {
        logger.error("", e);
    } finally {
        postMethod.releaseConnection();
    }
    return result;
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:20,代碼來源:HttpUtil.java

示例2: httpClientPost

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
public static final String httpClientPost(String url, ArrayList<NameValuePair> list) {
	String result = "";
	HttpClient client = new HttpClient();
	PostMethod postMethod = new PostMethod(url);
	try {
		NameValuePair[] params = new NameValuePair[list.size()];
		for (int i = 0; i < list.size(); i++) {
			params[i] = list.get(i);
		}
		postMethod.addParameters(params);
		client.executeMethod(postMethod);
		result = postMethod.getResponseBodyAsString();
	} catch (Exception e) {
		logger.error(e);
	} finally {
		postMethod.releaseConnection();
	}
	return result;
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:20,代碼來源:HttpUtil.java

示例3: executeQuery

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
private HttpMethod executeQuery(FederatedSearch sruSearch, String query, SRUSettings settings, int offset,
	int perpage) throws IOException
{
	HttpMethod httpMethod = null;

	try
	{
		// URL includes the port (if any) we trust ...
		URL url = new URL(settings.getUrl());
		PostMethod postMethod = new PostMethod(url.toExternalForm());
		NameValuePair[] nameValuePairs = populateNameValuePairs(query, settings, offset, perpage);
		postMethod.addParameters(nameValuePairs);
		httpMethod = postMethod;
	}
	catch( Exception e )
	{
		throw new RuntimeException(e);
	}

	HttpClient httpClient = new HttpClient();
	httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(sruSearch.getTimeout() * 1000);
	httpClient.getHttpConnectionManager().getParams().setSoTimeout(sruSearch.getTimeout() * 1000);
	// Prevent the default 3 tries - so once is enough ...?
	httpClient.getHttpConnectionManager().getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
		new DefaultHttpMethodRetryHandler(0, false));

	httpClient.executeMethod(httpMethod);

	return httpMethod;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:31,代碼來源:SruServiceImpl.java


注:本文中的org.apache.commons.httpclient.methods.PostMethod.addParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。