public class HttpUtils extends Object
| Constructor and Description |
|---|
HttpUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
httpMethodByStream(String sendMsg,
String accessUrl,
String requestMthod,
int connectTimeout,
int readTimeout)
http请求
|
static String |
httpPostMapByDefaultTime(String accessUrl,
Map<String,String> paraMap)
采用默认时间post请求,默认5s
|
static String |
httpPostStrByDefaultTime(String accessUrl,
String jsonStr)
采用默认时间post请求,默认5s
|
static String |
sendMapMsgByPost(String accessUrl,
Map<String,String> paraMap,
int connectTimeout,
int connectionRequestTimeout,
int socketTimeout)
Post请求参数为map类型
|
static String |
sendMsgByPostMethod(String accessUrl,
String jsonStr,
int connectTimeout,
int connectionRequestTimeout,
int socketTimeout)
采用httpclient方式以get方式进行请求
|
public static String httpMethodByStream(String sendMsg, String accessUrl, String requestMthod, int connectTimeout, int readTimeout)
sendMsg - 发送的数据accessUrl - 访问的地址requestMthod - 请求方法connectTimeout - 连接超时时间readTimeout - 读取超时时间public static String sendMsgByPostMethod(String accessUrl, String jsonStr, int connectTimeout, int connectionRequestTimeout, int socketTimeout) throws Exception
accessUrl - 请求地址jsonStr - 发送数据格式为jsonconnectTimeout - 连接超时时间connectionRequestTimeout - 连接请求超时时间socketTimeout - 读取超时时间Exceptionpublic static String sendMapMsgByPost(String accessUrl, Map<String,String> paraMap, int connectTimeout, int connectionRequestTimeout, int socketTimeout) throws Exception
accessUrl - 请求地址paraMap - 请求参数,key:参数名称,value:参数值connectTimeout - 连接超时时间connectionRequestTimeout - 连接请求超时时间socketTimeout - 读取超时时间Exceptionpublic static String httpPostStrByDefaultTime(String accessUrl, String jsonStr) throws Exception
accessUrl - 请求地址jsonStr - 请求json串ExceptionCopyright © 2021. All rights reserved.