![]() |
豪气的人字拖 · 配置 nginx ...· 4 月前 · |
![]() |
含蓄的汽水 · Pandas列中的字典/列表拆分为单独的列_ ...· 1 年前 · |
![]() |
爱搭讪的红金鱼 · 安卓测试。等待视图层次结构的根部拥有窗口焦点· 1 年前 · |
![]() |
强健的啄木鸟 · 存储过程返回布尔值以及C#相关处理 - ...· 1 年前 · |
![]() |
大气的电影票 · 如何将PDF文件批量打印?BatchOutp ...· 1 年前 · |
string uri resttemplate |
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html |
![]() |
痴情的拖把
2 年前 |
HttpURLConnection
, Apache HttpComponents, and others. RestTemplate
offers templates for common scenarios by HTTP method, in addition to the
generalized
exchange
and
execute
methods that support
less frequent cases.
RestTemplate is typically used as a shared component. However, its
configuration does not support concurrent modification, and as such its
configuration is typically prepared on startup. If necessary, you can create
multiple, differently configured RestTemplate instances on startup. Such
instances may use the same underlying
ClientHttpRequestFactory
if they need to share HTTP client resources.
NOTE:
As of 5.0 this class is in maintenance mode, with
only minor requests for changes and bugs to be accepted going forward. Please,
consider using the
org.springframework.web.reactive.client.WebClient
which has a more modern API and supports sync, async, and streaming scenarios.
HttpMessageConverter
RequestCallback
ResponseExtractor
ResponseErrorHandler
logger
RestTemplate
using default settings.
RestTemplate
(
List
<
HttpMessageConverter
<?>> messageConverters)
RestTemplate
using the given list of
HttpMessageConverter
to use.
RestTemplate
(
ClientHttpRequestFactory
requestFactory)
RestTemplate
based on the given
ClientHttpRequestFactory
.
acceptHeaderRequestCallback
(
Class
<T> responseType)
RequestCallback
that sets the request
Accept
header based on the given response type, cross-checked against the
configured message converters.
protected <T> T
doExecute
(
URI
url,
String
uriTemplate,
HttpMethod
method,
RequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor)
protected <T> T
doExecute
(
URI
url,
HttpMethod
method,
RequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor)
<T>
ResponseEntity
<T>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
Class
<T> responseType,
Object
... uriVariables)
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
Class
<T> responseType,
Map
<
String
,
?> uriVariables)
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType,
Object
... uriVariables)
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType,
Map
<
String
,
?> uriVariables)
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
URI
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
Class
<T> responseType)
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
URI
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType)
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
RequestEntity
<?> entity,
Class
<T> responseType)
RequestEntity
and return
the response as
ResponseEntity
.
<T>
ResponseEntity
<T>
exchange
(
RequestEntity
<?> entity,
ParameterizedTypeReference
<T> responseType)
RequestEntity
and return
the response as
ResponseEntity
.
execute
(
String
uriTemplate,
HttpMethod
method,
RequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor,
Object
... uriVariables)
RequestCallback
, and reading the response with a
ResponseExtractor
.
execute
(
String
uriTemplate,
HttpMethod
method,
RequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor,
Map
<
String
,
?> uriVariables)
RequestCallback
, and reading the response with a
ResponseExtractor
.
execute
(
URI
url,
HttpMethod
method,
RequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor)
RequestCallback
, and reading the response with a
ResponseExtractor
.
<T>
ResponseEntity
<T>
getForEntity
(
String
url,
Class
<T> responseType,
Object
... uriVariables)
<T>
ResponseEntity
<T>
getForEntity
(
String
url,
Class
<T> responseType,
Map
<
String
,
?> uriVariables)
<T>
ResponseEntity
<T>
getForEntity
(
URI
url,
Class
<T> responseType)
getForObject
(
String
url,
Class
<T> responseType,
Object
... uriVariables)
getForObject
(
String
url,
Class
<T> responseType,
Map
<
String
,
?> uriVariables)
getForObject
(
URI
url,
Class
<T> responseType)
List
<
HttpMessageConverter
<?>>
protected void
handleResponse
(
URI
url,
HttpMethod
method,
ClientHttpResponse
response)
ResponseErrorHandler
if necessary.
protected
ResponseExtractor
<
HttpHeaders
>
HttpHeaders
.
headForHeaders
(
String
url,
Object
... uriVariables)
headForHeaders
(
String
url,
Map
<
String
,
?> uriVariables)
headForHeaders
(
URI
url)
<T>
RequestCallback
httpEntityCallback
(
Object
requestBody)
RequestCallback
implementation that writes the given
object to the request stream.
<T>
RequestCallback
httpEntityCallback
(
Object
requestBody,
Type
responseType)
RequestCallback
implementation that:
Sets the request
Accept
header based on the given response
type, cross-checked against the configured message converters.
Set
<
HttpMethod
>
optionsForAllow
(
String
url,
Object
... uriVariables)
Allow
header for the given URI.
Set
<
HttpMethod
>
optionsForAllow
(
String
url,
Map
<
String
,
?> uriVariables)
Allow
header for the given URI.
Set
<
HttpMethod
>
optionsForAllow
(
URI
url)
Allow
header for the given URL.
patchForObject
(
String
url,
Object
request,
Class
<T> responseType,
Object
... uriVariables)
patchForObject
(
String
url,
Object
request,
Class
<T> responseType,
Map
<
String
,
?> uriVariables)
patchForObject
(
URI
url,
Object
request,
Class
<T> responseType)
<T>
ResponseEntity
<T>
postForEntity
(
String
url,
Object
request,
Class
<T> responseType,
Object
... uriVariables)
ResponseEntity
.
<T>
ResponseEntity
<T>
HttpEntity
.
<T>
ResponseEntity
<T>
postForEntity
(
URI
url,
Object
request,
Class
<T> responseType)
ResponseEntity
.
postForLocation
(
String
url,
Object
request,
Object
... uriVariables)
Location
header.
postForLocation
(
String
url,
Object
request,
Map
<
String
,
?> uriVariables)
Location
header.
postForLocation
(
URI
url,
Object
request)
Location
header.
postForObject
(
String
url,
Object
request,
Class
<T> responseType,
Object
... uriVariables)
postForObject
(
URI
url,
Object
request,
Class
<T> responseType)
<T>
ResponseExtractor
<
ResponseEntity
<T>>
responseEntityExtractor
(
Type
responseType)
ResponseExtractor
that prepares a
ResponseEntity
.
setDefaultUriVariables
(
Map
<
String
,
?> uriVars)
setErrorHandler
(
ResponseErrorHandler
errorHandler)
setMessageConverters
(
List
<
HttpMessageConverter
<?>> messageConverters)
setObservationConvention
(
ClientRequestObservationConvention
observationConvention)
ObservationConvention
that sets the name of the
observation
as well as its
KeyValues
extracted from the
ClientRequestObservationContext
.
setObservationRegistry
(io.micrometer.observation.ObservationRegistry observationRegistry)
ObservationRegistry
for collecting spans and metrics
for request execution.
setUriTemplateHandler
(
UriTemplateHandler
handler)
getInterceptors
,
getRequestFactory
,
setInterceptors
,
setRequestFactory
createRequest
,
getClientHttpRequestInitializers
,
setClientHttpRequestInitializers
clone
,
equals
,
finalize
,
getClass
,
hashCode
,
notify
,
notifyAll
,
toString
,
wait
,
wait
,
wait
RestTemplate
using default settings.
Default
HttpMessageConverters
are initialized.
RestTemplate
based on the given
ClientHttpRequestFactory
.
requestFactory
- the HTTP request factory to use
SimpleClientHttpRequestFactory
HttpComponentsClientHttpRequestFactory
RestTemplate
using the given list of
HttpMessageConverter
to use.
messageConverters
- the list of
HttpMessageConverter
to use
These converters are used to convert from and to HTTP requests and responses.
The returned
List
is active and may get appended to.
By default, RestTemplate uses a
DefaultResponseErrorHandler
.
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(); handler.setDefaultUriVariables(...); RestTemplate restTemplate = new RestTemplate(); restTemplate.setUriTemplateHandler(handler);
uriVars
- the default URI variable valuesBy default, DefaultUriBuilderFactory
is used and for
backwards compatibility, the encoding mode is set to
URI_COMPONENT
. As of 5.0.8, prefer
using TEMPLATE_AND_VALUES
.
handler
- the URI template handler to useObservationRegistry
for collecting spans and metrics
for request execution. By default, observations
are no-ops.observationRegistry
- the observation registry to useObservationConvention
that sets the name of the
observation
as well as its KeyValues
extracted from the ClientRequestObservationContext
.
If none set, the default convention
will be used.observationConvention
- the observation convention to usesetObservationRegistry(ObservationRegistry)
RestOperations
URI Template variables are expanded using the given URI variables, if any.
getForObject
in interface
RestOperations
url
- the URL
responseType
- the type of the return value
uriVariables
- the variables to expand the template
RestClientException
RestOperations
URI Template variables are expanded using the given map.
getForObject
in interface
RestOperations
url
- the URL
responseType
- the type of the return value
uriVariables
- the map containing variables for the URI template
RestClientException
RestOperations
getForObject
in interface
RestOperations
url
- the URL
responseType
- the type of the return value
RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
getForEntity
in interface
RestOperations
url
- the URL
responseType
- the type of the return value
uriVariables
- the variables to expand the template
RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given map.
getForEntity
in interface
RestOperations
url
- the URL
responseType
- the type of the return value
uriVariables
- the map containing variables for the URI template
RestClientException
RestOperations
ResponseEntity
.
getForEntity
in interface
RestOperations
url
- the URL
responseType
- the type of the return value
RestClientException
RestOperations
URI Template variables are expanded using the given URI variables, if any.
headForHeaders
in interface
RestOperations
url
- the URL
uriVariables
- the variables to expand the template
RestClientException
RestOperations
URI Template variables are expanded using the given map.
headForHeaders
in interface
RestOperations
url
- the URL
uriVariables
- the map containing variables for the URI template
RestClientException
RestOperations
headForHeaders
in interface
RestOperations
url
- the URL
RestClientException
RestOperations
Location
header. This header typically indicates where the new resource is stored.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForLocation
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Location
header
RestClientException
HttpEntity
RestOperations
Location
header. This header typically indicates where the new resource is stored.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForLocation
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Location
header
RestClientException
HttpEntity
RestOperations
Location
header. This header typically indicates where the new resource is stored.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForLocation
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
Location
header
RestClientException
HttpEntity
RestOperations
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForObject
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
RestOperations
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForObject
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
RestOperations
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForObject
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
responseType
- the type of the return value
RestClientException
HttpEntity
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForEntity
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
RestOperations
HttpEntity
.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForEntity
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
RestOperations
ResponseEntity
.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
postForEntity
in interface
RestOperations
url
- the URL
request
- the Object to be POSTed (may be
null
)
RestClientException
HttpEntity
RestOperations
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
put
in interface
RestOperations
url
- the URL
request
- the Object to be PUT (may be
null
)
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
RestOperations
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
put
in interface
RestOperations
url
- the URL
request
- the Object to be PUT (may be
null
)
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
RestOperations
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
put
in interface
RestOperations
url
- the URL
request
- the Object to be PUT (may be
null
)
RestClientException
HttpEntity
RestOperations
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH. You need to use the Apache HttpComponents or OkHttp request factory.
patchForObject
in interface
RestOperations
url
- the URL
request
- the object to be PATCHed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
RestOperations
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH. You need to use the Apache HttpComponents or OkHttp request factory.
patchForObject
in interface
RestOperations
url
- the URL
request
- the object to be PATCHed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
RestOperations
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH. You need to use the Apache HttpComponents or OkHttp request factory.
patchForObject
in interface
RestOperations
url
- the URL
request
- the object to be PATCHed (may be
null
)
responseType
- the type of the return value
RestClientException
HttpEntity
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
RestOperations
URI Template variables are expanded using the given URI variables, if any.
delete
in interface
RestOperations
url
- the URL
uriVariables
- the variables to expand in the template
RestClientException
RestOperations
URI Template variables are expanded using the given map.
delete
in interface
RestOperations
url
- the URL
uriVariables
- the variables to expand the template
RestClientException
RestOperations
delete
in interface
RestOperations
url
- the URL
RestClientException
RestOperations
Allow
header for the given URI.
URI Template variables are expanded using the given URI variables, if any.
optionsForAllow
in interface
RestOperations
url
- the URL
uriVariables
- the variables to expand in the template
Allow
header
RestClientException
RestOperations
Allow
header for the given URI.
URI Template variables are expanded using the given map.
optionsForAllow
in interface
RestOperations
url
- the URL
uriVariables
- the variables to expand in the template
Allow
header
RestClientException
RestOperations
Allow
header for the given URL.
optionsForAllow
in interface
RestOperations
url
- the URL
Allow
header
RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
exchange
in interface
RestOperations
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
uriVariables
- the variables to expand in the template
RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
exchange
in interface
RestOperations
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
uriVariables
- the variables to expand in the template
RestClientException
RestOperations
ResponseEntity
.
exchange
in interface
RestOperations
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
RestClientException
RestOperations
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; ResponseEntity<List<MyBean>> response = template.exchange("https://example.com",HttpMethod.GET, null, myBean);
exchange
in interface RestOperations
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the
request (may be null
)responseType
- the type to convert the response to, or Void.class
for no bodyuriVariables
- the variables to expand in the templateRestClientException
RestOperations
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; ResponseEntity<List<MyBean>> response = template.exchange("https://example.com",HttpMethod.GET, null, myBean);
exchange
in interface RestOperations
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
(may be null
)responseType
- the type to convert the response to, or Void.class
for no bodyuriVariables
- the variables to expand in the templateRestClientException
RestOperations
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; ResponseEntity<List<MyBean>> response = template.exchange("https://example.com",HttpMethod.GET, null, myBean);
exchange
in interface RestOperations
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
(may be null
)responseType
- the type to convert the response to, or Void.class
for no bodyRestClientException
RestOperations
RequestEntity
and return
the response as ResponseEntity
. Typically used in combination
with the static builder methods on RequestEntity
, for instance:
MyRequest body = ... RequestEntity request = RequestEntity .post(URI.create("https://example.com/foo")) .accept(MediaType.APPLICATION_JSON) .body(body); ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
exchange
in interface RestOperations
entity
- the entity to write to the requestresponseType
- the type to convert the response to, or Void.class
for no bodyRestClientException
RestOperations
RequestEntity
and return
the response as ResponseEntity
. The given
ParameterizedTypeReference
is used to pass generic type information:
MyRequest body = ... RequestEntity request = RequestEntity .post(URI.create("https://example.com/foo")) .accept(MediaType.APPLICATION_JSON) .body(body); ParameterizedTypeReference<List<MyResponse>> myBean = new ParameterizedTypeReference<List<MyResponse>>() {}; ResponseEntity<List<MyResponse>> response = template.exchange(request, myBean);
exchange
in interface RestOperations
entity
- the entity to write to the requestresponseType
- the type to convert the response to, or Void.class
for no bodyRestClientException
RequestCallback
, and reading the response with a ResponseExtractor
.
URI Template variables are expanded using the given URI variables, if any.
To provide a RequestCallback
or ResponseExtractor
only,
but not both, consider using:
acceptHeaderRequestCallback(Class)
httpEntityCallback(Object)
httpEntityCallback(Object, Type)
responseEntityExtractor(Type)
execute
in interface RestOperations
uriTemplate
- the URI templatemethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the responseuriVariables
- the variables to expand in the templateResponseExtractor
RestClientException
RequestCallback
, and reading the response with a ResponseExtractor
.
URI Template variables are expanded using the given URI variables map.
To provide a RequestCallback
or ResponseExtractor
only,
but not both, consider using:
acceptHeaderRequestCallback(Class)
httpEntityCallback(Object)
httpEntityCallback(Object, Type)
responseEntityExtractor(Type)
execute
in interface RestOperations
uriTemplate
- the URI templatemethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the responseuriVariables
- the variables to expand in the templateResponseExtractor
RestClientException
RequestCallback
, and reading the response with a ResponseExtractor
.
To provide a RequestCallback
or ResponseExtractor
only,
but not both, consider using:
acceptHeaderRequestCallback(Class)
httpEntityCallback(Object)
httpEntityCallback(Object, Type)
responseEntityExtractor(Type)
execute
in interface RestOperations
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the responseResponseExtractor
RestClientException
The ClientHttpRequest
is processed using the RequestCallback
;
the response with the ResponseExtractor
.
url
- the fully-expanded URL to connect tomethod
- the HTTP method to execute (GET, POST, etc.)requestCallback
- object that prepares the request (can be null
)responseExtractor
- object that extracts the return value from the response (can be null
)ResponseExtractor
RestClientException
The ClientHttpRequest
is processed using the RequestCallback
;
the response with the ResponseExtractor
.
url
- the fully-expanded URL to connect touriTemplate
- the URI template that was used for creating the expanded URLmethod
- the HTTP method to execute (GET, POST, etc.)requestCallback
- object that prepares the request (can be null
)responseExtractor
- object that extracts the return value from the response (can be null
)ResponseExtractor
RestClientException
ResponseErrorHandler
if necessary.
Can be overridden in subclasses.
url
- the fully-expanded URL to connect tomethod
- the HTTP method to execute (GET, POST, etc.)response
- the resulting ClientHttpResponse
IOException
- if propagated from ResponseErrorHandler
setErrorHandler(org.springframework.web.client.ResponseErrorHandler)
RequestCallback
that sets the request Accept
header based on the given response type, cross-checked against the
configured message converters.RequestCallback
implementation that writes the given
object to the request stream.RequestCallback
implementation that:
Accept
header based on the given response
type, cross-checked against the configured message converters.
ResponseExtractor
that prepares a ResponseEntity
.
![]() |
爱搭讪的红金鱼 · 安卓测试。等待视图层次结构的根部拥有窗口焦点 1 年前 |
doExecute(URI, String, HttpMethod, RequestCallback, ResponseExtractor)