zoukankan      html  css  js  c++  java
  • Android 使用httpClient POST 模拟发送 multipart表单内容

    使用的环境:apache-mime4j-0.6.jar,httpcore-4.3.2.jar,httpmime-4.3.3.jar

    try {
                        HttpPost httpPost = new HttpPost(GlobalData.urls.get("awsSub"));
                        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
                        multipartEntityBuilder.addTextBody("title", "send by mobile");
                        multipartEntityBuilder.addTextBody("id", "");
                        multipartEntityBuilder.addTextBody("op", "");
                        multipartEntityBuilder.addTextBody("type1", "1");
                        multipartEntityBuilder.addTextBody("ip", "");
                        multipartEntityBuilder.addTextBody("admuser", "");
                        multipartEntityBuilder.addTextBody("admpass", "");
                        multipartEntityBuilder.addTextBody("ftpname", "");
                        multipartEntityBuilder.addTextBody("url", "");
                        multipartEntityBuilder.addTextBody("Body", "手机端发送滴哟 内容");
                        multipartEntityBuilder.addTextBody("autofix", "1");
                        multipartEntityBuilder.addTextBody("Submitend", "提交");
                        multipartEntityBuilder.addTextBody("Submit", "继续发表");
                        multipartEntityBuilder.addTextBody("XQtitle", "");
                        multipartEntityBuilder.addTextBody("theBody", "");
                        multipartEntityBuilder.addBinaryBody("aboutimg1", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg2", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg3", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg4", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg5", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addTextBody("endtest", "");
    
                        httpPost.setEntity(multipartEntityBuilder.build());
                        HttpResponse httpResponse = HttpUtil.httpClient.execute(httpPost);
                        String txt = EntityUtils.toString(httpResponse.getEntity(),"gbk");
                        Intent intent = new Intent(KeFuActivity.this, ResultActivity.class);
                        intent.putExtra("html",txt);
                        startActivity(intent);
                    } catch (Exception e) {
                      e.printStackTrace();
                    }
  • 相关阅读:
    ABP WebApi的请求类型
    对服务器的文件或文件夹压缩
    VS运行遇到的那些坑
    asp.net core Api集成Swagger
    通过文件路径获取文件名
    读取服务器或者本地的文件夹下面的文件
    计算出 3 至 1000 范围内最大的十个素数,放入数组中,并计算出其累加和。
    LINUX 无法登入系统(2017-1-16)
    zynq里面的AXI总线(2017-1-11)
    学习随笔(2017-1-10)
  • 原文地址:https://www.cnblogs.com/wuyou/p/3640325.html
Copyright © 2011-2022 走看看