HttpClientUtil的使用

来源:互联网 发布:求大作战刷圣衣软件 编辑:程序博客网 时间:2024/05/29 16:14

当java源文件请求服务器时,返回数据一步相应,可以利用HttpClientUtil这个工具

例如:String url = "http://10.0.64.236:8080/asoapi/config/get_system_parameter?parameterCodes=AutoPublishForApplication&accessToken=001";
            String responseString = HttpClientUtil.httpGet(url);
            
            JSONObject responseJson = JSONObject.parseObject(responseString);
            int resultCode = responseJson.getIntValue("resultCode");
            if ( resultCode != 0 ) {
                return "Get error autoPublishedFlag";
            }
            JSONObject dataJson = JSONObject.parseObject(responseJson.getString("data"));
            String autoPublishedFlag = dataJson.getString("parameter1");

0 0
原创粉丝点击