接口 WebClient.RequestBodySpec
- 所有已知子接口:
WebClient.RequestBodyUriSpec
- 封闭接口:
- WebClient
public static interface WebClient.RequestBodySpec extends WebClient.RequestHeadersSpec<WebClient.RequestBodySpec>
Contract for specifying request headers and body leading up to the exchange.
方法概要
所有方法 实例方法 抽象方法 已过时的方法 修饰符和类型 方法 说明 WebClient.RequestHeadersSpec<?>body(Object producer, Class<?> elementClass)Variant ofbody(Publisher, Class)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.WebClient.RequestHeadersSpec<?>body(Object producer, ParameterizedTypeReference<?> elementTypeRef)Variant ofbody(Publisher, ParameterizedTypeReference)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.WebClient.RequestHeadersSpec<?>body(BodyInserter<?,? super ClientHttpRequest> inserter)Set the body of the request using the given body inserter.<T,P extends org.reactivestreams.Publisher<T>>
WebClient.RequestHeadersSpec<?>body(P publisher, Class<T> elementClass)Shortcut forbody(BodyInserter)with a Publisher inserter.<T,P extends org.reactivestreams.Publisher<T>>
WebClient.RequestHeadersSpec<?>body(P publisher, ParameterizedTypeReference<T> elementTypeRef)Variant ofbody(Publisher, Class)that allows providing element type information with generics.WebClient.RequestHeadersSpec<?>bodyValue(Object body)Shortcut forbody(BodyInserter)with a value inserter.WebClient.RequestBodySpeccontentLength(long contentLength)Set the length of the body in bytes, as specified by theContent-Lengthheader.WebClient.RequestBodySpeccontentType(MediaType contentType)Set the media type of the body, as specified by theContent-Typeheader.WebClient.RequestHeadersSpec<?>syncBody(Object body)已过时。as of Spring Framework 5.2 in favor ofbodyValue(Object)从接口继承的方法 org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec
accept, acceptCharset, attribute, attributes, cookie, cookies, exchange, header, headers, ifModifiedSince, ifNoneMatch, retrieve
方法详细资料
contentLength
WebClient.RequestBodySpec contentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Lengthheader.- 参数:
contentLength- the content length- 返回:
- this builder
- 另请参阅:
HttpHeaders.setContentLength(long)
contentType
WebClient.RequestBodySpec contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Typeheader.- 参数:
contentType- the content type- 返回:
- this builder
- 另请参阅:
HttpHeaders.setContentType(MediaType)
bodyValue
WebClient.RequestHeadersSpec<?> bodyValue(Object body)
Shortcut forbody(BodyInserter)with a value inserter. For example:Person person = ... ; Mono<Void> result = client.post() .uri("/persons/{id}", id) .contentType(MediaType.APPLICATION_JSON) .bodyValue(person) .retrieve() .bodyToMono(Void.class);For multipart requests consider providing
MultiValueMapprepared withMultipartBodyBuilder.- 参数:
body- the value to write to the request body- 返回:
- this builder
- 抛出:
IllegalArgumentException- ifbodyis aPublisheror producer known toReactiveAdapterRegistry- 从以下版本开始:
- 5.2
body
<T,P extends org.reactivestreams.Publisher<T>> WebClient.RequestHeadersSpec<?> body(P publisher, Class<T> elementClass)
Shortcut forbody(BodyInserter)with a Publisher inserter. For example:Mono<Person> personMono = ... ; Mono<Void> result = client.post() .uri("/persons/{id}", id) .contentType(MediaType.APPLICATION_JSON) .body(personMono, Person.class) .retrieve() .bodyToMono(Void.class);- 类型参数:
T- the type of the elements contained in the publisherP- the type of thePublisher- 参数:
publisher- thePublisherto write to the requestelementClass- the type of elements published- 返回:
- this builder
body
<T,P extends org.reactivestreams.Publisher<T>> WebClient.RequestHeadersSpec<?> body(P publisher, ParameterizedTypeReference<T> elementTypeRef)
Variant ofbody(Publisher, Class)that allows providing element type information with generics.- 类型参数:
T- the type of the elements contained in the publisherP- the type of thePublisher- 参数:
publisher- thePublisherto write to the requestelementTypeRef- the type of elements published- 返回:
- this builder
body
WebClient.RequestHeadersSpec<?> body(Object producer, Class<?> elementClass)
Variant ofbody(Publisher, Class)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.- 参数:
producer- the producer to write to the requestelementClass- the type of elements produced- 返回:
- this builder
- 从以下版本开始:
- 5.2
body
WebClient.RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef)
Variant ofbody(Publisher, ParameterizedTypeReference)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.- 参数:
producer- the producer to write to the requestelementTypeRef- the type of elements produced- 返回:
- this builder
- 从以下版本开始:
- 5.2
body
WebClient.RequestHeadersSpec<?> body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request using the given body inserter. SeeBodyInsertersfor built-inBodyInserterimplementations.- 参数:
inserter- the body inserter to use for the request body- 返回:
- this builder
- 另请参阅:
BodyInserters
syncBody
@Deprecated WebClient.RequestHeadersSpec<?> syncBody(Object body)
已过时。as of Spring Framework 5.2 in favor ofbodyValue(Object)Shortcut forbody(BodyInserter)with a value inserter. As of 5.2 this method delegates tobodyValue(Object).