あなたHttpParams HttpEntityEnclosedRequestBaseオブジェクトに設定HttpEntityを作成するために使用されていて、その後、次のコード
final HttpPost httpPost = new HttpPost("http://...");
final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("a_param", username));
params.add(new BasicNameValuePair("a_second_param", password));
// add the parameters to the httpPost
HttpEntity entity;
try
{
entity = new UrlEncodedFormEntity(params);
httpPost.setEntity(entity);
}
catch (final UnsupportedEncodingException e)
{
// this should never happen.
throw new IllegalStateException(e);
}
HttpEntity httpEntity = httpPost.getEntity();
try
{
List<NameValuePair> parameters = new ArrayList<NameValuePair>(URLEncodedUtils.parse(httpEntity));
}
catch (IOException e)
{
}
を使用してバックリストを持つことができます
私は、URIからパラメータを取り除くだけで同様のことをしました(これはGroovyのスニペットですが、Javaでも同じです)。 'def uri = new URI(" https://www.yahoo.com?foo = bar ") List parameters =新しいArrayList (URLEncodedUtils.parse(uri、" UTF-8 ")); parameters.each {parameter-> println parameter.name + ":" + parameter.value} ' これは、HttpParamsオブジェクトを使いこなすことなくリクエストのパラメータを分解するための適切な方法です。あなたが望むものを正確に知っている。 –