try {HttpClient http=new DefaultHttpClient();HttpPost post=new HttpPost(path);List parameters=new ArrayList();parameters.add(new BasicNameValuePair("mobile", hone));parameters.add(new BasicNameValuePair("password",pass));HttpEntity entity=new UrlEncodedFormEntity(parameters);post.setEntity(entity);HttpResponse execute = http.execute(post);HttpEntity entity2 = execute.getEntity();String json = EntityUtils.toString(entity2);Gson gson=new Gson();Bean bean = gson.fromJson(json, Bean.class);if("success".equals(bean.message)){Intent intent = new Intent(MainActivityLogin.this,MainActivity.class);intent.putExtra("login", bean);startActivity(intent);}} catch (ClientProtocolException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}
post解析
最新推荐文章于 2022-06-21 10:05:54 发布