public static String sendHttpRequestByPost(final String address,String encode,MatterReflectDTO dto){

        String result = "";

        DefaultHttpClient defaultHttpClient = new DefaultHttpClient();

        HttpPost httpPost = new HttpPost(address);


        String jsonString = dto.toString();


        try {

            StringEntity stringEntity = new StringEntity(new GsonBuilder().create().toJson(dto));

            System.out.println(stringEntity.toString());

            httpPost.setEntity(stringEntity);

            httpPost.setHeader("Accept", "application/json");

            httpPost.setHeader("Content-type", "application/json");

            httpPost.setHeader("Accept-Encoding", "gzip");


            HttpResponse httpResponse = defaultHttpClient.execute(httpPost);

            System.out.println("请求结果:"+httpResponse.getStatusLine().getStatusCode());

            int code = httpResponse.getStatusLine().getStatusCode();

            if(code ==200){

                InputStream is = httpResponse.getEntity().getContent();

                result = "true";


            }


        } catch (UnsupportedEncodingException e) {

            e.printStackTrace();  

        } catch (ClientProtocolException e) {

            e.printStackTrace(); 

        } catch (IOException e) {

            e.printStackTrace();  

        }

        return result;

    }

服务器端使用的是.net暂时就不贴出来了,需要注意的是并不是通过参数传递的。

更多相关文章

  1. android:布局参数,控件属性及各种xml的作用
  2. flutter插件开发学习之旅(7)-------双平台参数传递
  3. Android 版本 相关参数修改(SpreadTrum)
  4. Android访问WCF服务(使用json实现参数传递)
  5. android手机客户端上传文件,java servlet服务器端接收并保存到服
  6. Android中Activity之间访问互传参数
  7. Flutter 与 Android 相互调用、传递参数
  8. Android中Message参数传递
  9. Android中一个APP启动另一个APP并传递参数

随机推荐

  1. Android手动画柱状图的例子
  2. android之monkeyrunner截图及图像对比
  3. android学习笔记之十一数据存储(Shared P
  4. Android中的矢量动画
  5. Android设置View的margin
  6. 关于单选框RadioGroup和RadioButton
  7. Linux下Android(安卓)SDK环境搭建--使用
  8. Android三种播放视频的方式
  9. Android探索之旅 | AIDL原理和实例讲解
  10. Mac AndroidStudio真机调试