public void test(PayInfoDetailImpl payInfoDetailImpl) throws
IOException {
String url = xxxL;
String host = xxx;
String https = xxx;
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setHost(host, 80, https);
HttpMethod method = postMethod(url, payInfoDetailImpl);
httpClient.executeMethod(method);
String response = method.getResponseBodyAsString();
System.out.println(response);
}
/**
* post请求方法
*
* @param url
* @return
* @throws IOException
*/
private HttpMethod postMethod(String url,
PayInfoDetailImpl payInfoDetailImpl) throws IOException {
PayInfoImpl payInfoImpl = new PayInfoImpl();
System.out.println("返回地址: " + payInfoImpl.getPageUrl());
PostMethod post = new PostMethod(url);
post.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded;charset=gb2312");
String orderTime = new java.text.SimpleDateFormat("yyyyMMddHHmmss")
.format(new java.util.Date());
NameValuePair[] param = {
new NameValuePair("xxxx", xxx),
new NameValuePair("xxx",xxxx),
};
post.setRequestBody(param);
post.releaseConnection();
return post;
}
HttpClient POST请求
最新推荐文章于 2023-03-15 21:35:54 发布