zoukankan      html  css  js  c++  java
  • 每日总结

    1.使用HttpClient发送POST请求

    核心代码:

    private void PostByHttpClient(final String url)
    {
        new Thread()
        {
            public void run() 
            {
                try{
                    HttpClient httpClient = new DefaultHttpClient();
                    HttpPost httpPost = new HttpPost(url);
                    List<NameValuePair> params = new ArrayList<NameValuePair>();
                    params.add(new BasicNameValuePair("user", "猪大哥"));
                    params.add(new BasicNameValuePair("pawd", "123"));
                    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params,"UTF-8");
                    httpPost.setEntity(entity);
                    HttpResponse httpResponse =  httpClient.execute(httpPost);
                    if (httpResponse.getStatusLine().getStatusCode() == 200) {
                        HttpEntity entity2 = httpResponse.getEntity();
                        detail = EntityUtils.toString(entity2, "utf-8");
                        handler.sendEmptyMessage(SHOW_DATA);
                    }
                }catch(Exception e){e.printStackTrace();}
            };
        }.start();
    }
  • 相关阅读:
    为什么富人越来越富,穷人越来越穷?
    计算几何基础_点_向量_极角排序
    滑窗模板_双向队列
    后缀数组
    AC自动机
    RMQ_ST表
    二叉树求逆序对(伪AC 23333)
    分块
    莫队
    树状数组_二维
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14912244.html
Copyright © 2011-2022 走看看