zoukankan      html  css  js  c++  java
  • post请求提交表单数据

    //1.创建client对象
     HttpClient client = new DefaultHttpClient();
    //2.创建get请求对象
     HttpGet get = new HttpGet(path);
    //3.使用client发送get请求
     HttpResponse response = client.execute(get);
     //获取状态行
     StatusLine line = response.getStatusLine();
     //4.获取状态码
     int code = line.getStatusCode();  
     //5.获取实体
     HttpEntity entity = response.getEntity();  
       
    小部分代码:
    HttpClient client = new DefaultHttpClient();
                    //2.创建get请求对象
                    HttpGet get = new HttpGet(path);
                    try {
                        //3.使用client发送get请求
                        HttpResponse response = client.execute(get);
                        //获取状态行
                        StatusLine line = response.getStatusLine();
                        //获取状态码
                        int code = line.getStatusCode();
                        if(code == 200){
                            //获取实体
                            HttpEntity entity = response.getEntity();
                            InputStream is = entity.getContent();
                            String text = Tools.getTextFromStream(is);
                            
                            Message msg = handler.obtainMessage();
                            msg.obj = text;
                            handler.sendMessage(msg);
                        }
                        
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                        
  • 相关阅读:
    chapter4 quantum circuits
    《用广义CNOT门产生质数幂维的图态》
    幺正矩阵的分解
    SpringCloud学习----阳哥(五)
    SpringCloud学习----阳哥(四)
    SpringCloud学习----阳哥(三)
    SpringCloud学习----阳哥(二)
    SpringCloud学习----阳哥(一)
    IDEA插件介绍(一) -RestfulToolkit(接口自测工具)
    常用SQL语句和XML文件格式
  • 原文地址:https://www.cnblogs.com/SoulCode/p/6393418.html
Copyright © 2011-2022 走看看