Skip to content
Derek Hu edited this page Jul 25, 2015 · 4 revisions

POST数据请求方式: HttpPost request = new HttpPost(urlPath); List params = new ArrayList(); params.add(new BasicNameValuePair("name", username));//请求体,这里为用户名和密码 params.add(new BasicNameValuePair("password", passwd));// try { HttpEntity entity = new UrlEncodedFormEntity(params, "UTF-8");//设置编码格式 request.setEntity(entity);//pplplplplpl HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request);//发送请求,并等待response if(response.getStatusLine().getStatusCode() == 200){ String str = EntityUtils.toString(response.getEntity()); Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT).show(); }else{ Log.i(TAG_STRING, "erro");kkkk Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_SHORT).show(); }

Clone this wiki locally