org.apache.http.client.methods.HttpGet;
HttpGet method = new HttpGet(url.toExternalForm());
method.getParams()
Whare are these params?他們是查詢字符串?似乎沒有簡單的方法可以使用org.apache.http.client.methods.http Get對於HttpGet方法什麼是getParams()?
org.apache.http.client.methods.HttpGet;
HttpGet method = new HttpGet(url.toExternalForm());
method.getParams()
Whare are these params?他們是查詢字符串?似乎沒有簡單的方法可以使用org.apache.http.client.methods.http Get對於HttpGet方法什麼是getParams()?
按照Http Client tutorial,你可以這樣做:
URI uri = new URIBuilder()
.setScheme("http")
.setHost("www.google.com")
.setPath("/search")
.setParameter("q", "httpclient")
.setParameter("btnG", "Google Search")
.setParameter("aq", "f")
.setParameter("oq", "")
.build();
HttpGet httpget = new HttpGet(uri);
System.out.println(httpget.getURI());
添加查詢字符串這些參數是HTTP GET請求參數。
例如,在URL http://www.mysite.com/login?username=mcjones中,參數username具有值mcjones。
getParams
公共HttpMethodParams getParams()方法
Returns HTTP protocol parameters associated with this method. Specified by: getParams in interface HttpMethod Returns: HTTP parameters. Since: 3.0 See Also: HttpMethodParams
請求的參數的完整列表可以在http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html
問題是關於httpclient 4.x,你的答案是關於3.x. – user1338062 2013-11-28 16:01:59
@Mark Byers:鏈接固定並更新代碼 – 2013-10-03 21:39:14