本文整理汇总了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;
}
示例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;
}
示例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;
}