拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 java http 工具类

java http 工具类

白鹭 - 2022-02-02 1952 0 0
ackage org.fh.util;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;

/**
 * 说明:http 工具类
 * 作者:FH Admin
 * from:fhadmin.cn
 */
public class HttpUtil {

    public static String post(String requestUrl, String accessToken, String params)
            throws Exception {
        String contentType = "application/x-www-form-urlencoded";
        return HttpUtil.post(requestUrl, accessToken, contentType, params);
    }

    public static String post(String requestUrl, String accessToken, String contentType, String params)
            throws Exception {
        String encoding = "UTF-8";
        if (requestUrl.contains("nlp")) {
            encoding = "GBK";
        }
        return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding);
    }

    public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding)
            throws Exception {
        String url = requestUrl + "?access_token=" + accessToken;
        return HttpUtil.postGeneralUrl(url, contentType, params, encoding);
    }

    public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding)
            throws Exception {
        URL url = new URL(generalUrl);
        // 打开和URL之间的连接
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        // 设定通用的请求属性
        connection.setRequestProperty("Content-Type", contentType);
        connection.setRequestProperty("Connection", "Keep-Alive");
        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.setDoInput(true);

        // 得到请求的输出流物件
        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
        out.write(params.getBytes(encoding));
        out.flush();
        out.close();

        // 建立实际的连接
        connection.connect();
        // 获取所有回应头栏位
        Map<String, List<String>> headers = connection.getHeaderFields();
        // 遍历所有的回应头栏位
        for (String key : headers.keySet()) {
            System.err.println(key + "--->" + headers.get(key));
        }
        // 定义 BufferedReader输入流来读取URL的回应
        BufferedReader in = null;
        in = new BufferedReader(
                new InputStreamReader(connection.getInputStream(), encoding));
        String result = "";
        String getLine;
        while ((getLine = in.readLine()) != null) {
            result += getLine;
        }
        in.close();
        System.err.println("result:" + result);
        return result;
    }
}
 

1.模型管理 :web在线流程设计器、汇入汇出xml、复制流程、部署流程

2.流程管理 :汇入汇出流程资源档案、查看流程图、根据流程实体反射出流程模型、激活挂起

3.运行中流程:查看流程信息、当前任务节点、当前流程图、作废暂停流程、指派待办人、自由跳转

4.历史的流程:查看流程信息、流程用时、流程状态、查看任务发起人信息

5.待办任务 :查看本人个人任务以及本角色下的任务、办理、驳回、作废、指派一下代理人

6.已办任务 :查看自己办理过的任务以及流程信息、流程图、流程状态(作废 驳回 正常完成)

标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *