一次项目中用到httpclient:
主要功能是在后台给另一个系统的一个页面传递参数。
代码:
HttpClient httpclient = new HttpClient();
PostMethod post = new PostMethod(this.serviceUrl);
post.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
NameValuePair[] data = { new NameValuePair("alarmId",alarmNumber),
new NameValuePair("billId", Integer.toString(billid)),
new NameValuePair("sendMan",sendMan)
};
post.setRequestBody(data);
post.releaseConnection();
httpclient.executeMethod(post);
使用心得:
1.post.setRequestHeader里面的信息要设置正确。
相关资料:
1.很全面的httpclient整理说明:
[url]http://www.blogjava.net/Alpha/archive/2007/01/22/95216.html[/url]
主要功能是在后台给另一个系统的一个页面传递参数。
代码:
HttpClient httpclient = new HttpClient();
PostMethod post = new PostMethod(this.serviceUrl);
post.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
NameValuePair[] data = { new NameValuePair("alarmId",alarmNumber),
new NameValuePair("billId", Integer.toString(billid)),
new NameValuePair("sendMan",sendMan)
};
post.setRequestBody(data);
post.releaseConnection();
httpclient.executeMethod(post);
使用心得:
1.post.setRequestHeader里面的信息要设置正确。
相关资料:
1.很全面的httpclient整理说明:
[url]http://www.blogjava.net/Alpha/archive/2007/01/22/95216.html[/url]
本文介绍了一次项目中使用HTTPClient进行后台参数传递的具体实践。通过实例代码展示了如何设置请求头、构造请求体并发送POST请求。
4669

被折叠的 条评论
为什么被折叠?



