当前位置: 首页>>代码示例>>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;未经允许,请勿转载。