我對android非常陌生,並且在處理BasicHttpParams
時遇到了一些問題。BasicHttpParams無法按預期方式工作
我想打的網址,這種格式http://10.0.2.2:8080/test/j_spring_security_check?j_password=something&j_username=anbto&ajax=true&
這應該是一個POST
電話。該baseUrl
是http://10.0.2.2:8080/test/j_spring_security_check
和PARAMS我有一個Map<String,String>
哪個值[j_password:something, j_username:something, ajax:true]
我有這樣的代碼:
for(String param : params.keySet()) {
httpParams.setParameter(param, params.get(param));
}
其中httpParams
是BasicHttpParams
,當我打電話post.setParams(httpParams);
我得到的整體響應我頁。
我其實我應該只得到JSON作爲響應(因爲我設置ajax
參數去true
):
{"error":"Sorry, we were not able to find a user with that username and password."}
但事實並非如此。
但是,當我將baseUrl
更改爲http://10.0.2.2:8080/test/j_spring_security_check?j_password=something&j_username=anbto&ajax=true&
並跳過設置參數時,我得到了JSON響應。
不知道我犯了什麼錯誤。
在此先感謝。