在 Apache 的 httpclient 上向 HttpPost 添加参数
我正在尝试在 HttpPost 对象中设置一些 Http 参数。
HttpPost post=new HttpPost(url);
HttpParams params=new BasicHttpParams();
params.setParameter("param", "value");
post.setParams(params);
HttpResponse response = client.execute(post);
看起来参数根本没有设置。您知道为什么会发生这种情况吗?
谢谢
I am trying to set some Http parameters in the HttpPost object.
HttpPost post=new HttpPost(url);
HttpParams params=new BasicHttpParams();
params.setParameter("param", "value");
post.setParams(params);
HttpResponse response = client.execute(post);
It looks like the parameter is not set at all. Do you have any idea why this is happening?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些希望使用 HttpGet 找到答案的人,这里有一个(来自 https://stackoverflow.com/a/4660576/330867) :
注意:这没有考虑
your_url
的状态:如果已经有一些参数,如果已经包含“?”等。我假设您知道如何编码/搜索并将根据您的情况进行调整。For those who hopes to find the answer using HttpGet, here's one (from https://stackoverflow.com/a/4660576/330867) :
NOTE: This doesn't take in consideration the state of
your_url
: if there is already some parameters, if it already contains a "?", etc. I assume you know how to code/search and will adapt regarding your case.