接口 ServerResponse
- 所有已知子接口:
EntityResponse<T>,RenderingResponse
public interface ServerResponse
Represents a typed server-side HTTP response, as returned by a handler function or filter function.- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma, Juergen Hoeller, Sebastien Deleuze
嵌套类概要
嵌套类 修饰符和类型 接口 说明 static interfaceServerResponse.BodyBuilderDefines a builder that adds a body to the response.static interfaceServerResponse.ContextDefines the context used during thewriteTo(ServerWebExchange, Context).static interfaceServerResponse.HeadersBuilder<B extends ServerResponse.HeadersBuilder<B>>Defines a builder that adds headers to the response.
方法概要
所有方法 静态方法 实例方法 抽象方法 修饰符和类型 方法 说明 static ServerResponse.BodyBuilderaccepted()Create a builder with an 202 Accepted status.static ServerResponse.BodyBuilderbadRequest()Create a builder with a 400 Bad Request status.MultiValueMap<String,ResponseCookie>cookies()Return the cookies of this response.static ServerResponse.BodyBuildercreated(URI location)Create a new builder with a 201 Created status and a location header set to the given URI.static ServerResponse.BodyBuilderfrom(ServerResponse other)Create a builder with the status code and headers of the given response.HttpHeadersheaders()Return the headers of this response.static ServerResponse.HeadersBuilder<?>noContent()Create a builder with a 204 No Content status.static ServerResponse.HeadersBuilder<?>notFound()Create a builder with a 404 Not Found status.static ServerResponse.BodyBuilderok()Create a builder with the status set to 200 OK.static ServerResponse.BodyBuilderpermanentRedirect(URI location)Create a builder with a 308 Permanent Redirect status and a location header set to the given URI.intrawStatusCode()Return the (potentially non-standard) status code of this response.static ServerResponse.BodyBuilderseeOther(URI location)Create a builder with a 303 See Other status and a location header set to the given URI.static ServerResponse.BodyBuilderstatus(int status)Create a builder with the given HTTP status.static ServerResponse.BodyBuilderstatus(HttpStatus status)Create a builder with the given HTTP status.HttpStatusstatusCode()Return the status code of this response.static ServerResponse.BodyBuildertemporaryRedirect(URI location)Create a builder with a 307 Temporary Redirect status and a location header set to the given URI.static ServerResponse.BodyBuilderunprocessableEntity()Create a builder with an 422 Unprocessable Entity status.reactor.core.publisher.Mono<Void>writeTo(ServerWebExchange exchange, ServerResponse.Context context)Write this response to the given web exchange.
方法详细资料
statusCode
HttpStatus statusCode()
Return the status code of this response.- 返回:
- the status as an HttpStatus enum value
- 抛出:
IllegalArgumentException- in case of an unknown HTTP status code- 另请参阅:
HttpStatus.valueOf(int)
rawStatusCode
int rawStatusCode()
Return the (potentially non-standard) status code of this response.- 返回:
- the status as an integer
- 从以下版本开始:
- 5.2
- 另请参阅:
statusCode(),HttpStatus.resolve(int)
headers
HttpHeaders headers()
Return the headers of this response.
cookies
MultiValueMap<String,ResponseCookie> cookies()
Return the cookies of this response.
writeTo
reactor.core.publisher.Mono<Void> writeTo(ServerWebExchange exchange, ServerResponse.Context context)
Write this response to the given web exchange.- 参数:
exchange- the web exchange to write tocontext- the context to use when writing- 返回:
Mono<Void>to indicate when writing is complete
from
static ServerResponse.BodyBuilder from(ServerResponse other)
Create a builder with the status code and headers of the given response.- 参数:
other- the response to copy the status and headers from- 返回:
- the created builder
status
static ServerResponse.BodyBuilder status(HttpStatus status)
Create a builder with the given HTTP status.- 参数:
status- the response status- 返回:
- the created builder
status
static ServerResponse.BodyBuilder status(int status)
Create a builder with the given HTTP status.- 参数:
status- the response status- 返回:
- the created builder
- 从以下版本开始:
- 5.0.3
ok
static ServerResponse.BodyBuilder ok()
Create a builder with the status set to 200 OK.- 返回:
- the created builder
created
static ServerResponse.BodyBuilder created(URI location)
Create a new builder with a 201 Created status and a location header set to the given URI.- 参数:
location- the location URI- 返回:
- the created builder
accepted
static ServerResponse.BodyBuilder accepted()
Create a builder with an 202 Accepted status.- 返回:
- the created builder
noContent
static ServerResponse.HeadersBuilder<?> noContent()
Create a builder with a 204 No Content status.- 返回:
- the created builder
seeOther
static ServerResponse.BodyBuilder seeOther(URI location)
Create a builder with a 303 See Other status and a location header set to the given URI.- 参数:
location- the location URI- 返回:
- the created builder
temporaryRedirect
static ServerResponse.BodyBuilder temporaryRedirect(URI location)
Create a builder with a 307 Temporary Redirect status and a location header set to the given URI.- 参数:
location- the location URI- 返回:
- the created builder
permanentRedirect
static ServerResponse.BodyBuilder permanentRedirect(URI location)
Create a builder with a 308 Permanent Redirect status and a location header set to the given URI.- 参数:
location- the location URI- 返回:
- the created builder
badRequest
static ServerResponse.BodyBuilder badRequest()
Create a builder with a 400 Bad Request status.- 返回:
- the created builder
notFound
static ServerResponse.HeadersBuilder<?> notFound()
Create a builder with a 404 Not Found status.- 返回:
- the created builder
unprocessableEntity
static ServerResponse.BodyBuilder unprocessableEntity()
Create a builder with an 422 Unprocessable Entity status.- 返回:
- the created builder