org.springframework.web.reactive.result.view

## Class ViewResolutionResultHandler

- java.lang.Object
- - org.springframework.web.reactive.result.HandlerResultHandlerSupport
  - - org.springframework.web.reactive.result.view.ViewResolutionResultHandler

- All Implemented Interfaces:
    Ordered, HandlerResultHandler

      public class ViewResolutionResultHandler
      extends HandlerResultHandlerSupport
      implements HandlerResultHandler, Ordered

  `HandlerResultHandler` that encapsulates the view resolution algorithm supporting the following return types:
  - `Void` or no value -- default view name
  - `String` -- view name unless `@ModelAttribute`-annotated
  - `View` -- View to render with
  - `Model` -- attributes to add to the model
  - `Map` -- attributes to add to the model
  - `Rendering` -- use case driven API for view resolution
  - `@ModelAttribute` -- attribute for the model
  - Non-simple value -- attribute for the model

  A String-based view name is resolved through the configured `ViewResolver` instances into a `View` to use for rendering. If a view is left unspecified (e.g. by returning `null` or a model-related return value), a default view name is selected.

  By default this resolver is ordered at `Ordered.LOWEST_PRECEDENCE` and generally needs to be late in the order since it interprets any String return value as a view name or any non-simple value type as a model attribute while other result handlers may interpret the same otherwise based on the presence of annotations, e.g. for `@ResponseBody`.

  Since:
    5.0
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    - ### Fields inherited from class org.springframework.web.reactive.result.HandlerResultHandlerSupport

      `logger`

    - ### Fields inherited from interface org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ViewResolutionResultHandler(List<ViewResolver> viewResolvers, RequestedContentTypeResolver contentTypeResolver)` Basic constructor with a default `ReactiveAdapterRegistry`.
    `ViewResolutionResultHandler(List<ViewResolver> viewResolvers, RequestedContentTypeResolver contentTypeResolver, ReactiveAdapterRegistry registry)` Constructor with an `ReactiveAdapterRegistry` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<View>` | `getDefaultViews()` Return the configured default `View`'s.
    `List<ViewResolver>` | `getViewResolvers()` Return a read-only list of view resolvers.
    `reactor.core.publisher.Mono<Void>` | `handleResult(ServerWebExchange exchange, HandlerResult result)` Process the given result modifying response headers and/or writing data to the response.
    `void` | `setDefaultViews(List<View> defaultViews)` Set the default views to consider always when resolving view names and trying to satisfy the best matching content type.
    `boolean` | `supports(HandlerResult result)` Whether this handler supports the given `HandlerResult`.

    - ### Methods inherited from class org.springframework.web.reactive.result.HandlerResultHandlerSupport

      `getAdapter, getAdapterRegistry, getContentTypeResolver, getOrder, selectMediaType, setOrder`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.core.Ordered

      `getOrder`

- - ### Constructor Detail

    - #### ViewResolutionResultHandler

          public ViewResolutionResultHandler(List<ViewResolver> viewResolvers,
                                             RequestedContentTypeResolver contentTypeResolver)

      Basic constructor with a default `ReactiveAdapterRegistry`.
      Parameters:
        `viewResolvers` - the resolver to use
        `contentTypeResolver` - to determine the requested content type

    - #### ViewResolutionResultHandler

          public ViewResolutionResultHandler(List<ViewResolver> viewResolvers,
                                             RequestedContentTypeResolver contentTypeResolver,
                                             ReactiveAdapterRegistry registry)

      Constructor with an `ReactiveAdapterRegistry` instance.
      Parameters:
        `viewResolvers` - the view resolver to use
        `contentTypeResolver` - to determine the requested content type
        `registry` - for adaptation to reactive types

  - ### Method Detail

    - #### getViewResolvers

          public List<ViewResolver> getViewResolvers()

      Return a read-only list of view resolvers.

    - #### setDefaultViews

          public void setDefaultViews(@Nullable
                                      List<View> defaultViews)

      Set the default views to consider always when resolving view names and trying to satisfy the best matching content type.

    - #### getDefaultViews

          public List<View> getDefaultViews()

      Return the configured default `View`'s.

    - #### supports

          public boolean supports(HandlerResult result)

      Description copied from interface: `HandlerResultHandler`
      Whether this handler supports the given `HandlerResult`.
      Specified by:
        `supports` in interface `HandlerResultHandler`
      Parameters:
        `result` - the result object to check
      Returns:
        whether this object can use the given result

    - #### handleResult

          public reactor.core.publisher.Mono<Void> handleResult(ServerWebExchange exchange,
                                                                HandlerResult result)

      Description copied from interface: `HandlerResultHandler`
      Process the given result modifying response headers and/or writing data to the response.
      Specified by:
        `handleResult` in interface `HandlerResultHandler`
      Parameters:
        `exchange` - current server exchange
        `result` - the result from the handling
      Returns:
        `Mono<Void>` to indicate when request handling is complete.