标签:
HttpClient client = new HttpClient(); String url = http://localhost:8080/ana/workFlowOaInterface.do?action=oaTask; PostMethod postMethod = new PostMethod(url); //设置参数编码为gbk post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"gbk"); //构造键值对参数 NameValuePair[] data = { new NameValuePair("processInstanceId", "230"), new NameValuePair("approveFlag", "1") }; // 把参数值放入postMethod中 postMethod.setRequestBody(data); //执行
int code = client.executeMethod(postMethod);//获取执行结果代码
//读取内容 byte[] responseBody = postMethod.getResponseBody(); //处理内容 System.out.println(new String(responseBody)); System.out.println("getStatusLine:"+postMethod.getStatusLine()); System.out.println("~~~"+postMethod.getResponseBodyAsString()); System.out.println("statusCode:"+statusCode); //打印结果页面 String response = new String(postMethod.getResponseBodyAsString().getBytes("utf-8")); //打印返回的信息 System.out.println("response:"+response); //释放连接 postMethod.releaseConnection();
标签:
原文地址:http://www.cnblogs.com/azhqiang/p/4673316.html