Android HTTPPOST请求报错
publicvoidregister(Stringurl,StringuserName,StringpassWord){newAsyncTask<String,Void,...
public void register(String url,String userName,String passWord){ new AsyncTask<String, Void, String>(){ @Override protected String doInBackground(String... params) { //分别获取三个参数 1.POST请求地址 2.用户名 3.密码 String url = params[0]; String userName = params[1]; String passWord = params[2]; //建立POST请求 HttpPost post = new HttpPost(url);
try { //POST请求需要接收表单,所以用List作为表单 List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>(); list.add(new BasicNameValuePair("userName",userName)); list.add(new BasicNameValuePair("passWord",passWord)); post.setEntity(new UrlEncodedFormEntity(list)); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } //HttpResponse try { HttpResponse response = client.execute(post); String result = EntityUtils.toString(response.getEntity()); resultTextView.setText(result); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }.execute(url); 展开
try { //POST请求需要接收表单,所以用List作为表单 List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>(); list.add(new BasicNameValuePair("userName",userName)); list.add(new BasicNameValuePair("passWord",passWord)); post.setEntity(new UrlEncodedFormEntity(list)); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } //HttpResponse try { HttpResponse response = client.execute(post); String result = EntityUtils.toString(response.getEntity()); resultTextView.setText(result); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }.execute(url); 展开
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询