日期:2014-05-16 浏览次数:20759 次
public String doHttpSend(String keyWord,String searchType,int pageNum) throws Exception { PostMethod method = null; try { HttpClient client = getHttpClient(); method = new PostMethod(SEARCH_URL); method.addRequestHeader("connection","keep-alive"); NameValuePair[] params = new NameValuePair[]{ new NameValuePair("keyWord",keyWord), new NameValuePair("page",String.valueOf(pageNum)) }; method.addParameters(params); int statusCode = client.executeMethod(method); if(statusCode != HttpStatus.SC_OK) { return null; } System.out.println(method.getResponseBodyAsString()); return method.getResponseBodyAsString(); } finally { if(null != method) { method.releaseConnection(); } } }