如何在一个HttpURLConnection中使用Java做几个请求?来自一个HttpURLConnection的几个请求
URL url = new URL("http://my.com");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
HttpURLConnection.setFollowRedirects(true);
connection.setDoOutput(true);
connection.setRequestMethod("GET");
PrintStream ps = new PrintStream(connection.getOutputStream());
ps.print(params);
ps.close();
connection.connect();
//TODO: do next request with other url, but in same connection
谢谢。
我正要说同样的事情,关于它并非意味着被重复使用 – 2010-03-16 19:53:24
有+1,那么!通常我会在我的答案中痛苦很久,以至于每个人都打我。 :) – 2010-03-16 19:54:47
@CarlSmotricz可能是真的,...但在我的情况下,我得到了许多请求,太多没有任何get/post参数+ 1与get参数,....我只使用简单的代码为httpconnection。 http://stackoverflow.com/questions/23017813/httpurlconnection-lots-of-requests – Bhuro 2016-07-16 10:47:54