您的位置:首页 > 理论基础 > 计算机网络

http请求

2016-01-20 18:45 483 查看
NameValuePair[] data = { new NameValuePair("userName", "aaa"),

                new NameValuePair("userPwd", "aaa") };

        requestURL = "http://www.baidu.com";

        HttpClient httpClient = new HttpClient();

        PostMethod postMethod = new PostMethod(requestURL);

        postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");

        postMethod.setRequestBody(data);

        int statusCode = httpClient.executeMethod(postMethod);

        logger.info("statusCode  ----------: " + statusCode);

        String result = postMethod.getResponseBodyAsString();

        if (result == null) {

            result = "";

        }

        logger.info(result);

        return JSONObject.fromObject(result);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: