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