来自apache的调用HttpClient的标准用法[b](version 3.1)[/b]
HttpClient httpclient = new HttpClient();
GetMethod httpget = new GetMethod("https://www.verisign.com/");
try {
httpclient.executeMethod(httpget);
System.out.println(httpget.getStatusLine());
} finally {
httpget.releaseConnection();
}
需要执行 httpclient.executeMethod(httpget); 否则后面用到httpget会报空指针异常。
其他的连接样例可参考官网:http://hc.apache.org/httpclient-3.x/sslguide.html
HttpClient httpclient = new HttpClient();
GetMethod httpget = new GetMethod("https://www.verisign.com/");
try {
httpclient.executeMethod(httpget);
System.out.println(httpget.getStatusLine());
} finally {
httpget.releaseConnection();
}
需要执行 httpclient.executeMethod(httpget); 否则后面用到httpget会报空指针异常。
其他的连接样例可参考官网:http://hc.apache.org/httpclient-3.x/sslguide.html