2、HttpClient4?主要是HttpConnection没有连接池的概念,多少次请求就会建立多少个IO,在访问量巨大的情况下服务器的IO可能会耗尽。HttpClient3也有连接池的东西在里头,使用MultiThreadedHttpConnectionManager,大致过程如下:[java]viewplaincopyprint?1.MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); 2.HttpCli
3、ent client = new HttpClient(connectionManager);...// 在某个线程中。 3.GetMethod get = new GetMethod("http://jakarta.apache.org/"); 4.try { 5.client.executeMethod(get);// print response to stdout 6.System.out.println(get.getResponseBodyAsStream()); 7.} finally { 8.// be sure th
4、e connection is released back to the connection 9.managerget.releaseConnection(); 10.} MultiThreadedHttpConnectionManagerconnectionManager=newMultiThreadedHttpConnectionManager();HttpClientclient=newHttpClient(connectionManager);...//在某个线程中。GetMethodget=newGetMethod("http