看来如果我这里有这段代码...
someGetMethod =
new HttpGet("http://www.website.com/blah/Action?test1=1&Test2=2");
奇怪的是,我生成了这个 http 请求 header 。请注意 Action
缺失且 URL 错误
GET /blah/?test1=1&Test2=2
有人知道为什么这个错误会发生在 HttpComponents 中吗?
最佳答案
所以有一个错误。它位于构造函数中调用 new HttpGet("URI...")
。
这解决了问题...
HttpGet someGet new HttpGet();
someGet.setURI(new URI(url));
关于Java HttpComponents 不使用原始 URL 进行 GET 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12200108/