对于HttpGet方法,getParams()是什么?

时间:2010-06-07 12:28:45

标签: java apache-httpclient-4.x

org.apache.http.client.methods.HttpGet;

HttpGet method = new HttpGet(url.toExternalForm());
method.getParams()

Whare是这些参数吗?它们是查询字符串吗?似乎没有简单的方法来添加org.apache.http.client.methods.HttpGet的查询字符串

3 个答案:

答案 0 :(得分:14)

根据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());

答案 1 :(得分:0)

这些参数是HTTP GET请求参数。

例如,在网址 http://www.mysite.com/login?username=mcjones 中,参数username的值为mcjones。

答案 2 :(得分:0)

来自http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethodBase.html#getParams%28%29

  

getParams

     

public 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

找到请求的完整参数列表