我跟着this other SO question設置參數的URL,但它給錯誤:將查詢參數添加到GetMethod(使用Java commons-httpclient)?
The method
setQueryString(String)
in the typeHttpMethodBase
is not applicable for the arguments(NameValuePair[])
和
Cannot instantiate the type
NameValuePair
.
我無法瞭解實際問題。有人能幫我解決這個問題嗎?
我從上面的問題中使用的代碼
GetMethod method = new GetMethod("example.com/page";);
method.setQueryString(new NameValuePair[] {
new NameValuePair("key", "value")
});
沒有ü這裏除去多餘的分號' 「example.com/page」;' – vikingsteve 2013-04-26 07:43:22
您正在使用的HttpClient 3.x或4.x的?你給的例子是典型的3.x代碼,而不是4.x. – NilsH 2013-04-26 07:43:55
Vikingsteve在移除代碼時已經移除了這個分號 – 2013-04-26 07:46:05