|
@@ -18,6 +18,7 @@ import javax.net.ssl.TrustManager; |
|
@@ -18,6 +18,7 @@ import javax.net.ssl.TrustManager; |
|
18
|
import javax.net.ssl.X509TrustManager;
|
18
|
import javax.net.ssl.X509TrustManager;
|
|
19
|
import org.slf4j.Logger;
|
19
|
import org.slf4j.Logger;
|
|
20
|
import org.slf4j.LoggerFactory;
|
20
|
import org.slf4j.LoggerFactory;
|
|
|
|
21
|
+import com.ruoyi.common.constant.Constants;
|
|
21
|
|
22
|
|
|
22
|
/**
|
23
|
/**
|
|
23
|
* 通用http发送方法
|
24
|
* 通用http发送方法
|
|
@@ -37,6 +38,19 @@ public class HttpUtils |
|
@@ -37,6 +38,19 @@ public class HttpUtils |
|
37
|
*/
|
38
|
*/
|
|
38
|
public static String sendGet(String url, String param)
|
39
|
public static String sendGet(String url, String param)
|
|
39
|
{
|
40
|
{
|
|
|
|
41
|
+ return sendGet(url, param, Constants.UTF8);
|
|
|
|
42
|
+ }
|
|
|
|
43
|
+
|
|
|
|
44
|
+ /**
|
|
|
|
45
|
+ * 向指定 URL 发送GET方法的请求
|
|
|
|
46
|
+ *
|
|
|
|
47
|
+ * @param url 发送请求的 URL
|
|
|
|
48
|
+ * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
|
|
|
49
|
+ * @param contentType 编码类型
|
|
|
|
50
|
+ * @return 所代表远程资源的响应结果
|
|
|
|
51
|
+ */
|
|
|
|
52
|
+ public static String sendGet(String url, String param, String contentType)
|
|
|
|
53
|
+ {
|
|
40
|
StringBuilder result = new StringBuilder();
|
54
|
StringBuilder result = new StringBuilder();
|
|
41
|
BufferedReader in = null;
|
55
|
BufferedReader in = null;
|
|
42
|
try
|
56
|
try
|
|
@@ -49,7 +63,7 @@ public class HttpUtils |
|
@@ -49,7 +63,7 @@ public class HttpUtils |
|
49
|
connection.setRequestProperty("connection", "Keep-Alive");
|
63
|
connection.setRequestProperty("connection", "Keep-Alive");
|
|
50
|
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
64
|
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
|
51
|
connection.connect();
|
65
|
connection.connect();
|
|
52
|
- in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "GBK"));
|
66
|
+ in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
|
|
53
|
String line;
|
67
|
String line;
|
|
54
|
while ((line = in.readLine()) != null)
|
68
|
while ((line = in.readLine()) != null)
|
|
55
|
{
|
69
|
{
|