| Constructor and Description |
|---|
RestClient() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
exchange(org.springframework.http.HttpHeaders httpHeaders,
org.springframework.http.MediaType contentType,
URI uri,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType)
自定义发送HTTP请求
|
static <T> T |
exchange(org.springframework.http.HttpHeaders httpHeaders,
org.springframework.http.MediaType contentType,
URI uri,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType,
RestRequestCallback restRequestCallback)
自定义发送HTTP请求
|
static <T> T |
exchange(org.springframework.http.MediaType contentType,
String url,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType,
Object... uriVariables)
自定义发送HTTP请求
|
static <T> T |
exchange(org.springframework.http.MediaType contentType,
URI uri,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType)
自定义发送HTTP请求
|
static <T> T |
getForObject(org.springframework.http.HttpHeaders httpHeaders,
String url,
org.springframework.util.LinkedMultiValueMap<String,String> parameterMap,
Class<T> responseType,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap |
static <T> T |
getForObject(org.springframework.http.HttpHeaders httpHeaders,
String url,
Map<String,String> parameterMap,
Class<T> responseType,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap |
static <T> T |
getForObject(String url,
org.springframework.util.LinkedMultiValueMap<String,String> parameterMap,
Class<T> responseType,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap |
static <T> T |
getForObject(String url,
Map<String,String> parameterMap,
Class<T> responseType,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap |
static String |
getForString(org.springframework.http.HttpHeaders httpHeaders,
String url,
org.springframework.util.LinkedMultiValueMap<String,String> parameterMap,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap,返回的数据是字符串类型 |
static String |
getForString(org.springframework.http.HttpHeaders httpHeaders,
String url,
Map<String,String> parameterMap,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap,返回的数据是字符串类型 |
static String |
getForString(org.springframework.http.HttpHeaders httpHeaders,
String url,
Object... uriVariables)
以GET方法发送HTTP请求,返回的数据是字符串类型
|
static String |
getForString(String url,
org.springframework.util.LinkedMultiValueMap<String,String> parameterMap,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap,返回的数据是字符串类型 |
static String |
getForString(String url,
Map<String,String> parameterMap,
Object... uriVariables)
以GET方法发送HTTP请求,并在请求的url中添加动态参数
parameterMap,返回的数据是字符串类型 |
static String |
getForString(String url,
Object... uriVariables)
以GET方法发送HTTP请求,返回的数据是字符串类型
|
static org.springframework.web.client.RestTemplate |
getRestTemplate()
获取发送 HTTP 请求的 RestTemplate
|
static String |
postForm(org.springframework.http.HttpHeaders httpHeaders,
String url,
org.springframework.util.LinkedMultiValueMap<String,String> requestBody,
Object... uriVariables)
以POST方法发送HTTP请求,请求的内容为form数据格式
|
static String |
postForm(String url,
org.springframework.util.LinkedMultiValueMap<String,String> requestBody,
Object... uriVariables)
以POST方法发送HTTP请求,请求的内容为form数据格式
|
static String |
postJson(org.springframework.http.HttpHeaders httpHeaders,
String url,
String requestBody,
Object... uriVariables)
以POST方法发送HTTP请求,请求的内容为JSON
|
static String |
postJson(String url,
String requestBody,
Object... uriVariables)
以POST方法发送HTTP请求,请求的内容为JSON
|
static void |
setCoreCommonProperties(org.springframework.boot.context.event.ApplicationReadyEvent event)
订阅 Spring 容器准备完毕的事件,初始化通用网关配置
|
@EventListener public static void setCoreCommonProperties(org.springframework.boot.context.event.ApplicationReadyEvent event)
event - Spring 容器准备完毕的事件public static org.springframework.web.client.RestTemplate getRestTemplate()
public static <T> T exchange(org.springframework.http.HttpHeaders httpHeaders,
org.springframework.http.MediaType contentType,
URI uri,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType,
RestRequestCallback restRequestCallback)
T - 数据类型class的泛形httpHeaders - 自定义HttpHeaderscontentType - Internet Media Type,互联网媒体类型uri - 请求的urimethod - 请求方法类型requestBody - 请求的内容responseType - 返回的数据类型restRequestCallback - 回调函数,用于在发送请求之前,做某些处理操作;也可用于在返回结果之前,做某些处理操作public static <T> T exchange(org.springframework.http.HttpHeaders httpHeaders,
org.springframework.http.MediaType contentType,
URI uri,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType)
T - 数据类型class的泛形httpHeaders - 自定义HttpHeaderscontentType - Internet Media Type,互联网媒体类型uri - 请求的urimethod - 请求方法类型requestBody - 请求的内容responseType - 返回的数据类型public static <T> T exchange(org.springframework.http.MediaType contentType,
URI uri,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType)
T - 数据类型class的泛形contentType - Internet Media Type,互联网媒体类型uri - 请求的urimethod - 请求方法类型requestBody - 请求的内容responseType - 返回的数据类型public static <T> T exchange(org.springframework.http.MediaType contentType,
String url,
org.springframework.http.HttpMethod method,
Object requestBody,
Class<T> responseType,
Object... uriVariables)
T - 数据类型class的泛形contentType - Internet Media Type,互联网媒体类型url - 请求的url,url中可以包含占位符{0}, {1}, {n}method - 请求方法类型requestBody - 请求的内容responseType - 返回的数据类型uriVariables - url中占位符的参数值public static String postJson(String url, String requestBody, Object... uriVariables)
url - 请求的url,url中可以包含占位符{0}, {1}, {n}requestBody - 请求的内容uriVariables - url中占位符的参数值public static String postJson(org.springframework.http.HttpHeaders httpHeaders, String url, String requestBody, Object... uriVariables)
httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}requestBody - 请求的内容uriVariables - url中占位符的参数值public static String postForm(String url, org.springframework.util.LinkedMultiValueMap<String,String> requestBody, Object... uriVariables)
url - 请求的url,url中可以包含占位符{0}, {1}, {n}requestBody - 请求的内容uriVariables - url中占位符的参数值public static String postForm(org.springframework.http.HttpHeaders httpHeaders, String url, org.springframework.util.LinkedMultiValueMap<String,String> requestBody, Object... uriVariables)
httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}requestBody - 请求的内容uriVariables - url中占位符的参数值public static <T> T getForObject(String url, Map<String,String> parameterMap, Class<T> responseType, Object... uriVariables)
parameterMapT - 泛型url - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中responseType - 返回的数据类型uriVariables - url中占位符的参数值public static <T> T getForObject(org.springframework.http.HttpHeaders httpHeaders,
String url,
Map<String,String> parameterMap,
Class<T> responseType,
Object... uriVariables)
parameterMapT - 泛型httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中responseType - 返回的数据类型uriVariables - url中占位符的参数值public static String getForString(String url, Map<String,String> parameterMap, Object... uriVariables)
parameterMap,返回的数据是字符串类型url - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中uriVariables - url中占位符的参数值public static String getForString(org.springframework.http.HttpHeaders httpHeaders, String url, Map<String,String> parameterMap, Object... uriVariables)
parameterMap,返回的数据是字符串类型httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中uriVariables - url中占位符的参数值public static String getForString(String url, Object... uriVariables)
url - 请求的url,url中可以包含占位符{0}, {1}, {n}uriVariables - url中占位符的参数值public static String getForString(org.springframework.http.HttpHeaders httpHeaders, String url, Object... uriVariables)
httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}uriVariables - url中占位符的参数值public static <T> T getForObject(String url, org.springframework.util.LinkedMultiValueMap<String,String> parameterMap, Class<T> responseType, Object... uriVariables)
parameterMapT - 泛型url - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中responseType - 返回的数据类型uriVariables - url中占位符的参数值public static <T> T getForObject(org.springframework.http.HttpHeaders httpHeaders,
String url,
org.springframework.util.LinkedMultiValueMap<String,String> parameterMap,
Class<T> responseType,
Object... uriVariables)
parameterMapT - 泛型httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中responseType - 返回的数据类型uriVariables - url中占位符的参数值public static String getForString(String url, org.springframework.util.LinkedMultiValueMap<String,String> parameterMap, Object... uriVariables)
parameterMap,返回的数据是字符串类型url - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中uriVariables - url中占位符的参数值public static String getForString(org.springframework.http.HttpHeaders httpHeaders, String url, org.springframework.util.LinkedMultiValueMap<String,String> parameterMap, Object... uriVariables)
parameterMap,返回的数据是字符串类型httpHeaders - 自定义HttpHeadersurl - 请求的url,url中可以包含占位符{0}, {1}, {n}parameterMap - 请求的参数,将会添加到url中uriVariables - url中占位符的参数值Copyright © 2018–2020 Pivotal Software, Inc.. All rights reserved.