我有一个制作 httpPost 的代码,但我无法使用数组中的参数记录,但如果我制作所有完整的 url,我将毫无问题地记录!,我错过了什么?
String URL = "http://domain.com/projexct/form.aspx"; //won't work
// String URL = "http://domain.com/projexct/form.aspx?user=aa&pass=11";
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("user", "aa"));
nameValuePairs.add(new BasicNameValuePair("pass", "11"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpClient.execute(httpPost);
EDIT1 它不会抛出错误,但是如果我在 namevaluePairs 中使用参数,它只会显示登录页面,如果我使用注释的 URL,它实际上会登录。