【发布时间】:2011-10-11 12:05:22
【问题描述】:
我通常用这个:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(postURL);
...
HttpResponse responsePOST = client.execute(post);
是否可以在同一个请求中同时传递 GET 和 POST 的参数? 我的意思是有些参数可能很长……我不想使用 GET,我想要 POST,但对某些人来说我确实想要 GET。
那么?
【问题讨论】:
-
这是 apache 的
HttpClient,对吗? -
为什么不呢?它似乎是使用 Apache HttpClient API 的有效代码。
-
GET 和 POST 的含义略有不同。您不应该仅仅因为参数可能太长而使用其中一个。见What is the difference between GET and POST?。 (GET 只能用于幂等操作)。
-
@Guillaume Harry 对原始问题的意思是“不”,而不是对 mre 的评论。
-
我阅读了这篇文章(+ wikipedia for "idempotence")......在最后一节中它指出〜对于大型数据使用 POST。但是,是的,不能同时使用。
标签: java apache post get httpclient