2010-06-07 6 views
5
org.apache.http.client.methods.HttpGet; 

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

¿Cuáles son estos parámetros? ¿Son la cadena de consulta? no parece haber una manera fácil de agregar una cadena de consulta con org.apache.http.client.methods.HttpGetPara un método HttpGet, ¿qué son getParams()?

Respuesta

14

De acuerdo con la Http Client tutorial, usted puede hacer esto:

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()); 
+0

@ Mark Byers: Enlace fijo y código actualizado –

0

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

getParams

getParams HttpMethodParams públicos()

Returns HTTP protocol parameters associated with this method. 

Specified by: 
    getParams in interface HttpMethod 

Returns: 
    HTTP parameters. 
Since: 
    3.0 
See Also: 
    HttpMethodParams 

La lista completa de parámetros para la solicitud se puede encontrar en http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html

+0

La pregunta es acerca de httpclient 4.x, su respuesta es aproximadamente 3.x. – user1338062

Cuestiones relacionadas