我对 android 很陌生,使用BasicHttpParams.
我希望以这种格式点击这个网址http://10.0.2.2:8080/test/j_spring_security_check?j_password=something&j_username=anbto&ajax=true&
这应该是一个POST电话。baseUrlis和http://10.0.2.2:8080/test/j_spring_security_checkparams 我有一个Map<String,String>which 值是[j_password:something, j_username:something, ajax:true]
我有这样的代码:
for(String param : params.keySet()) {
httpParams.setParameter(param, params.get(param));
}
httpParamsa在哪里BasicHttpParams,当我打电话时,post.setParams(httpParams);我会得到页面的全部响应。
实际上,我应该只得到 JSON 作为响应(因为我将ajaxparam 设置为true):
{"error":"Sorry, we were not able to find a user with that username and password."}
但事实并非如此。
但是当我更改baseUrltohttp://10.0.2.2:8080/test/j_spring_security_check?j_password=something&j_username=anbto&ajax=true&并跳过设置 params 时,我得到 JSON 响应。
不知道我在哪里犯了错误。
提前致谢。