HttpClient使用

一次项目中用到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整理说明:
      http://www.blogjava.net/Alpha/archive/2007/01/22/95216.html

你可能感兴趣的:(html,.net)