接口 ResponseEntity.HeadersBuilder<B extends ResponseEntity.HeadersBuilder<B>>

类型参数:
B - the builder subclass
所有已知子接口:
ResponseEntity.BodyBuilder
所有已知实现类:
ResponseEntity.DefaultBuilder
封闭类:
ResponseEntity<T>

public static interface ResponseEntity.HeadersBuilder<B extends ResponseEntity.HeadersBuilder<B>>
Defines a builder that adds headers to the response entity.
  • 方法概要

    修饰符和类型
    方法
    说明
    allow(HttpMethod... allowedMethods)
    Set the set of allowed HTTP methods, as specified by the Allow header.
    Build the response entity with no body.
    cacheControl(CacheControl cacheControl)
    Set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.
    eTag(String etag)
    Set the entity tag of the body, as specified by the ETag header.
    header(String headerName, String... headerValues)
    Add the given, single header value under the given name.
    Copy the given headers into the entity's headers map.
    headers(Consumer<HttpHeaders> headersConsumer)
    Manipulate this entity's headers with the given consumer.
    lastModified(long lastModified)
    Set the time the resource was last changed, as specified by the Last-Modified header.
    lastModified(Instant lastModified)
    Set the time the resource was last changed, as specified by the Last-Modified header.
    Set the time the resource was last changed, as specified by the Last-Modified header.
    location(URI location)
    Set the location of a resource, as specified by the Location header.
    varyBy(String... requestHeaders)
    Configure one or more request header names (e.g.
  • 方法详细资料

    • header

      B header(String headerName, String... headerValues)
      Add the given, single header value under the given name.
      参数:
      headerName - the header name
      headerValues - the header value(s)
      返回:
      this builder
      另请参阅:
    • headers

      B headers(@Nullable HttpHeaders headers)
      Copy the given headers into the entity's headers map.
      参数:
      headers - the existing HttpHeaders to copy from
      返回:
      this builder
      另请参阅:
    • headers

      B headers(Consumer<HttpHeaders> headersConsumer)
      Manipulate this entity's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the other HttpHeaders methods.
      参数:
      headersConsumer - a function that consumes the HttpHeaders
      返回:
      this builder
    • allow

      B allow(HttpMethod... allowedMethods)
      Set the set of allowed HTTP methods, as specified by the Allow header.
      参数:
      allowedMethods - the allowed methods
      返回:
      this builder
      另请参阅:
    • eTag

      B eTag(@Nullable String etag)
      Set the entity tag of the body, as specified by the ETag header.
      参数:
      etag - the new entity tag
      返回:
      this builder
      另请参阅:
    • lastModified

      B lastModified(ZonedDateTime lastModified)
      Set the time the resource was last changed, as specified by the Last-Modified header.
      参数:
      lastModified - the last modified date
      返回:
      this builder
      另请参阅:
    • lastModified

      B lastModified(Instant lastModified)
      Set the time the resource was last changed, as specified by the Last-Modified header.
      参数:
      lastModified - the last modified date
      返回:
      this builder
      另请参阅:
    • lastModified

      B lastModified(long lastModified)
      Set the time the resource was last changed, as specified by the Last-Modified header.

      The date should be specified as the number of milliseconds since January 1, 1970 GMT.

      参数:
      lastModified - the last modified date
      返回:
      this builder
      另请参阅:
    • location

      B location(URI location)
      Set the location of a resource, as specified by the Location header.
      参数:
      location - the location
      返回:
      this builder
      另请参阅:
    • cacheControl

      B cacheControl(CacheControl cacheControl)
      Set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.

      A CacheControl instance can be built like CacheControl.maxAge(3600).cachePublic().noTransform().

      参数:
      cacheControl - a builder for cache-related HTTP response headers
      返回:
      this builder
      另请参阅:
    • varyBy

      B varyBy(String... requestHeaders)
      Configure one or more request header names (e.g. "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers. The configured request header names are added only if not already present in the response "Vary" header.
      参数:
      requestHeaders - request header names
    • build

      <T> ResponseEntity<T> build()
      Build the response entity with no body.
      返回:
      the response entity
      另请参阅: