我有一个AsyncTask
设置创建一个AndroidHttpClient
并打电话Execute
,有一个HttpPost
and BasicHttpContext
我提供的对象。我设置了HttpPost
像这样:
HttpPost myPost = new HttpPost("http://192.168.1.66:8080/login.html");
BasicHttpParams httpParams = new BasicHttpParams();
httpParams.setParameter("cmd", "Login");
httpParams.setParameter("Username", "test");
httpParams.setParameter("Password", "password");
myPost.setParams(httpParams);
当我执行命令时,它检索的是登录页面而不是登录结果。在服务器端监控进程后,似乎这是因为HTTP请求到达时没有附加参数!那么我错过了什么?
HttpPost post = new HttpPost("http://192.168.1.66:8080/login.html");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
3);
nameValuePairs.add(new BasicNameValuePair("cmd", "Login"
.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("Username", "test"
.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("Password", "Password"
.getText().toString()));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)