Package io.micronaut.views
Class DefaultViewsResolver
java.lang.Object
io.micronaut.views.DefaultViewsResolver
- All Implemented Interfaces:
ViewsResolver
@Singleton
@Requires(classes=io.micronaut.http.HttpRequest.class)
public class DefaultViewsResolver
extends Object
implements ViewsResolver
Default implementation of
ViewsResolver
.
It checks if the route is annotated with View
or returns a ModelAndView
instance.- Since:
- 3.0.0
- Author:
- Sergio del Amo
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionresolveView
(io.micronaut.core.annotation.AnnotationMetadata route, @Nullable Object responseBody) Resolves the view for the given method and response body.resolveView
(io.micronaut.http.HttpRequest<?> request, io.micronaut.http.HttpResponse<?> response)
-
Constructor Details
-
DefaultViewsResolver
public DefaultViewsResolver()
-
-
Method Details
-
resolveView
@NonNull public @NonNull Optional<String> resolveView(io.micronaut.http.HttpRequest<?> request, io.micronaut.http.HttpResponse<?> response) - Specified by:
resolveView
in interfaceViewsResolver
- Parameters:
request
- HTTP Requestresponse
- HTTP Response- Returns:
- The view name if resolved
-
resolveView
protected Optional<String> resolveView(io.micronaut.core.annotation.AnnotationMetadata route, @Nullable @Nullable Object responseBody) Resolves the view for the given method and response body. Subclasses can override to customize.- Parameters:
route
- Request routeresponseBody
- Response body- Returns:
- view name to be rendered
-