【发布时间】:2011-08-15 22:08:16
【问题描述】:
您好,我在提交简单表单时遇到了很多麻烦,我四处搜索,似乎有不少人遇到过同样的问题,但我没有找到答案。
到目前为止,这是我的代码:
public void postData(TextView txtResult, String user, String pass) throws ClientProtocolException, IOException {
HttpPost post = new HttpPost("https://www.mymeteor.ie");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", user));
nameValuePairs.add(new BasicNameValuePair("userpass", pass));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);
txtResult.setText(responseText);
}
上面的代码只会返回原始页面,
谁能帮帮我?
谢谢
【问题讨论】: