1
13693261870
2022-09-16 58d012f11dd34564d81b4eb3a6099eb689876597
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//package org.apereo.cas.web.landtool.utils;
//
////import com.alibaba.fastjson.JSONArray;
////import com.alibaba.fastjson.JSONObject;
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpResponse;
//import org.apache.http.NameValuePair;
//import org.apache.http.client.HttpClient;
//import org.apache.http.client.entity.UrlEncodedFormEntity;
//import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.DefaultHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
//import org.apache.http.impl.nio.client.HttpAsyncClients;
//import org.apache.http.message.BasicNameValuePair;
//import org.apache.http.util.EntityUtils;
//
//import java.io.IOException;
//import java.lang.reflect.Field;
//import java.lang.reflect.Type;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.Iterator;
//import java.util.LinkedHashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.Map.Entry;
//import java.util.concurrent.Future;
//
///**
// * @author
// * @Description: TODO(获取字典信息)
// * @date 2018-3-22 15:09
// */
//public class HttpAsyncUtils {
//    /**
//     * HttpGet 请求 URL 返回数据
//     * 
//     * @param url
//     * @return
//     * @throws IOException
//     */
//    public static String httpGet(String url) throws IOException {
//        HttpClient client = new DefaultHttpClient();
//        HttpGet request = new HttpGet(url.trim());
//        HttpResponse httpResponse = client.execute(request);
//        HttpEntity httpEntity = httpResponse.getEntity();
//        return EntityUtils.toString(httpEntity, "UTF-8");
//    }
//
//    // public static <T> T getJsonObject(String url, Class<T> clazz)
//    // throws IOException {
//    // String resultjson = HttpOperateUtils.httpGet(url);
//    // JSONObject jsonobject = JSONObject.parseObject(resultjson);
//    // return JSONObject.toJavaObject(jsonobject, clazz);
//    // }
//    //
//    // public static <T> List<T> getJsonObjectArray(String url, Class<T> clazz)
//    // throws IOException {
//    // String resultjson = HttpOperateUtils.httpGet(url);
//    // return JSONObject.parseArray(resultjson, clazz);
//    // }
//
//    /**
//     * HttpPost
//     */
//    public static String httpPost(String url, Object obj) throws IOException {
//        String charset = "utf-8";
//        HttpClient httpClient = null;
//        HttpPost httpPost = null;
//        String result = null;
//        try {
//            Map<String, String> map = objectToMap(obj);
//            httpClient = new DefaultHttpClient();
//            httpPost = new HttpPost(url);
//            // 设置参数
//            List<NameValuePair> list = new ArrayList<NameValuePair>();
//            Iterator iterator = map.entrySet().iterator();
//            while (iterator.hasNext()) {
//                Entry<String, String> elem = (Entry<String, String>) iterator.next();
//                if (elem.getValue() != null) {
//                    list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
//                }
//            }
//            if (list.size() > 0) {
//                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, charset);
//                httpPost.setEntity(entity);
//            }
//            httpClient.execute(httpPost);
//
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
//
//        return result;
//    }
//
//    public static String httpPostSync(String url, Object obj) throws IOException, IllegalAccessException {
//        Map<String, String> map = objectToMap(obj);
//        return httpPostSync(url, map);
//    }
//
//    /***
//     * 创建对象 CloseableHttpAsyncClient 有问题
//     * 
//     * @param url
//     * @param obj
//     * @return
//     * @throws IOException
//     */
//    public static String httpPostSync(String url, Map<String, String> paramMap) throws IOException {
//        CloseableHttpAsyncClient httpClient = null;
//        String charset = "utf-8";
//        HttpPost httpPost = null;
//        String result = null;
//        try {
//            Map<String, String> map = null;
//            if (paramMap != null) {
//                map = paramMap;
//            }
//
//            httpClient = HttpAsyncClients.createDefault();
//            httpClient.start();
//
//            httpPost = new HttpPost(url);
//            // 设置参数
//            List<NameValuePair> list = new ArrayList<NameValuePair>();
//            Iterator iterator = map.entrySet().iterator();
//            while (iterator.hasNext()) {
//                Entry<String, String> elem = (Entry<String, String>) iterator.next();
//                if (elem.getValue() != null) {
//                    list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
//                }
//            }
//            if (list.size() > 0) {
//                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, charset);
//                httpPost.setEntity(entity);
//            }
//            httpClient.execute(httpPost, null);
//
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }finally {
//            if(httpClient !=null) {
//                httpClient.close();
//            }
//        }
//
//        return result;
//    }
//
//    public static void main(String[] args) {
//        final CloseableHttpAsyncClient httpClient = HttpAsyncClients.createDefault();
//        httpClient.start();
//        System.out.println(11);
//    }
//
//    /**
//     * 获取利用反射获取类里面的值和名称
//     * 
//     * @param obj
//     * @return
//     * @throws IllegalAccessException
//     */
//    public static Map<String, String> objectToMap(Object obj) throws IllegalAccessException {
//        Map<String, String> map = new HashMap<String, String>();
//        Class<?> clazz = obj.getClass();
//        for (Field field : clazz.getDeclaredFields()) {
//            field.setAccessible(true);
//            String fieldName = field.getName();
//            String value = field.get(obj) != null ? String.valueOf(field.get(obj)) : null;
//            map.put(fieldName, value);
//        }
//        return map;
//    }
//
//}