public class RestTemplateUtil extends Object
| 构造器和说明 |
|---|
RestTemplateUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
getForEntity(String url,
Class<T> responseType)
通用指定返回对象类型
|
static <T> T |
getForObject(String url,
Class<T> responseType)
通用指定返回对象类型
|
static String |
getForString(String url)
GET 请求,支持 Https
|
static File |
postForFile(String url,
String params)
使用JSON参数发送Post请求,支持 Https
|
static String |
postForString(String url,
String params)
使用JSON参数发送Post请求,支持 Https
|
static File |
postJsonForFile(String url,
String params)
使用JSON参数发送Post请求,支持微信小程序的 Https
|
static String |
postJsonForString(String url,
String params)
使用JSON参数发送Post请求,支持微信小程序的 Https
|
public static <T> T getForObject(String url, Class<T> responseType)
T - 方法内部泛型url - 请求地址responseType - 返回的类型public static <T> T getForEntity(String url, Class<T> responseType)
T - 方法内部泛型url - 请求地址responseType - 返回的类型public static String getForString(String url)
url - 请求地址public static String postForString(String url, String params)
url - 请求地址params - 参数: code=abc123&token=abcpublic static File postForFile(String url, String params) throws IOException
url - 请求地址params - 参数: code=abc123&token=abcIOExceptionpublic static String postJsonForString(String url, String params)
url - 请求地址params - 参数为 JSON 格式的参数: { "key" : 520, "key1" : 1314 }public static File postJsonForFile(String url, String params) throws IOException
url - 请求地址params - 参数为 JSON 格式的参数: { "key" : 520, "key1" : 1314 }IOExceptionCopyright © 2022. All rights reserved.