Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.config.annotation

public Class ViewResolverRegistry

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collections, .List, org.springframework.beans.factory.BeanFactoryUtils, .BeanInitializationException, org.springframework.context.ApplicationContext, org.springframework.core.Ordered, org.springframework.lang.Nullable, org.springframework.util.CollectionUtils, .ObjectUtils, org.springframework.web.accept.ContentNegotiationManager, org.springframework.web.servlet.View, .ViewResolver, org.springframework.web.servlet.view.BeanNameViewResolver, .ContentNegotiatingViewResolver, .InternalResourceViewResolver, org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer, .FreeMarkerViewResolver, org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer, .GroovyMarkupViewResolver, org.springframework.web.servlet.view.script.ScriptTemplateConfigurer, .ScriptTemplateViewResolver

Assist with the configuration of a chain of ViewResolver instances. This class is expected to be used via WebMvcConfigurer#configureViewResolvers.
Authors
Sebastien Deleuze, Rossen Stoyanchev
Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final ApplicationContext
private ContentNegotiatingViewResolver
private final ContentNegotiationManager
private Integer
private final List<ViewResolver>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
beanName()

Register a bean name view resolver that interprets view names as the names of org.springframework.web.servlet.View beans.

private boolean
checkBeanOfType(Class<?> beanType)

public void
enableContentNegotiation(View... defaultViews)

Enable use of a ContentNegotiatingViewResolver to front all other configured view resolvers and select among all selected Views based on media types requested by the client (e.g. in the Accept header).

public void
enableContentNegotiation(boolean useNotAcceptableStatus, View... defaultViews)

Enable use of a ContentNegotiatingViewResolver to front all other configured view resolvers and select among all selected Views based on media types requested by the client (e.g. in the Accept header).

public UrlBasedViewResolverRegistration
freeMarker()

Register a FreeMarker view resolver with an empty default view name prefix and a default suffix of ".ftl".

protected int
protected List<ViewResolver>
public UrlBasedViewResolverRegistration
groovy()

Register a Groovy markup view resolver with an empty default view name prefix and a default suffix of ".tpl".

public boolean
hasRegistrations()

Whether any view resolvers have been registered.

private ContentNegotiatingViewResolver
public UrlBasedViewResolverRegistration
jsp()

Register JSP view resolver using a default view name prefix of "/WEB-INF/" and a default suffix of ".jsp".

public UrlBasedViewResolverRegistration
jsp(String prefix, String suffix)

Register JSP view resolver with the specified prefix and suffix.

public void
order(int order)

ViewResolver's registered through this registry are encapsulated in an instance of ViewResolverComposite and follow the order of registration.

public UrlBasedViewResolverRegistration
scriptTemplate()

Register a script template view resolver with an empty default view name prefix and suffix.

public void
viewResolver(ViewResolver viewResolver)

Register a ViewResolver bean instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationContextback to summary
private final ApplicationContext applicationContext
Annotations
@Nullable
contentNegotiatingResolverback to summary
private ContentNegotiatingViewResolver contentNegotiatingResolver
Annotations
@Nullable
contentNegotiationManagerback to summary
private final ContentNegotiationManager contentNegotiationManager
Annotations
@Nullable
orderback to summary
private Integer order
Annotations
@Nullable
viewResolversback to summary
private final List<ViewResolver> viewResolvers

Constructor Detail

ViewResolverRegistryback to summary
public ViewResolverRegistry(ContentNegotiationManager contentNegotiationManager, ApplicationContext context)

Class constructor with ContentNegotiationManager and ApplicationContext.

Since
4.3.12

Method Detail

beanNameback to summary
public void beanName()

Register a bean name view resolver that interprets view names as the names of org.springframework.web.servlet.View beans.

checkBeanOfTypeback to summary
private boolean checkBeanOfType(Class<?> beanType)
enableContentNegotiationback to summary
public void enableContentNegotiation(View... defaultViews)

Enable use of a ContentNegotiatingViewResolver to front all other configured view resolvers and select among all selected Views based on media types requested by the client (e.g. in the Accept header).

If invoked multiple times the provided default views will be added to any other default views that may have been configured already.

See Also
ContentNegotiatingViewResolver#setDefaultViews
enableContentNegotiationback to summary
public void enableContentNegotiation(boolean useNotAcceptableStatus, View... defaultViews)

Enable use of a ContentNegotiatingViewResolver to front all other configured view resolvers and select among all selected Views based on media types requested by the client (e.g. in the Accept header).

If invoked multiple times the provided default views will be added to any other default views that may have been configured already.

See Also
ContentNegotiatingViewResolver#setDefaultViews
freeMarkerback to summary
public UrlBasedViewResolverRegistration freeMarker()

Register a FreeMarker view resolver with an empty default view name prefix and a default suffix of ".ftl".

Note

that you must also configure FreeMarker by adding a org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer bean.

getOrderback to summary
protected int getOrder()
getViewResolversback to summary
protected List<ViewResolver> getViewResolvers()
groovyback to summary
public UrlBasedViewResolverRegistration groovy()

Register a Groovy markup view resolver with an empty default view name prefix and a default suffix of ".tpl".

hasRegistrationsback to summary
public boolean hasRegistrations()

Whether any view resolvers have been registered.

initContentNegotiatingViewResolverback to summary
private ContentNegotiatingViewResolver initContentNegotiatingViewResolver(View[] defaultViews)
jspback to summary
public UrlBasedViewResolverRegistration jsp()

Register JSP view resolver using a default view name prefix of "/WEB-INF/" and a default suffix of ".jsp".

When this method is invoked more than once, each call will register a new ViewResolver instance. Note that since it's not easy to determine if a JSP exists without forwarding to it, using multiple JSP-based view resolvers only makes sense in combination with the "viewNames" property on the resolver indicating which view names are handled by which resolver.

jspback to summary
public UrlBasedViewResolverRegistration jsp(String prefix, String suffix)

Register JSP view resolver with the specified prefix and suffix.

When this method is invoked more than once, each call will register a new ViewResolver instance. Note that since it's not easy to determine if a JSP exists without forwarding to it, using multiple JSP-based view resolvers only makes sense in combination with the "viewNames" property on the resolver indicating which view names are handled by which resolver.

orderback to summary
public void order(int order)

ViewResolver's registered through this registry are encapsulated in an instance of ViewResolverComposite and follow the order of registration. This property determines the order of the ViewResolverComposite itself relative to any additional ViewResolver's (not registered here) present in the Spring configuration

By default this property is not set, which means the resolver is ordered at Ordered#LOWEST_PRECEDENCE unless content negotiation is enabled in which case the order (if not set explicitly) is changed to Ordered#HIGHEST_PRECEDENCE.

scriptTemplateback to summary
public UrlBasedViewResolverRegistration scriptTemplate()

Register a script template view resolver with an empty default view name prefix and suffix.

Since
4.2
viewResolverback to summary
public void viewResolver(ViewResolver viewResolver)

Register a ViewResolver bean instance. This may be useful to configure a custom (or 3rd party) resolver implementation. It may also be used as an alternative to other registration methods in this class when they don't expose some more advanced property that needs to be set.

org.springframework.web.servlet.config.annotation back to summary

private Class ViewResolverRegistry.FreeMarkerRegistration

extends UrlBasedViewResolverRegistration
Class Inheritance

Field Summary

Inherited from org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration:
viewResolver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration:
attributescachecacheLimitgetViewResolverprefixsuffixviewClassviewNames

Constructor Detail

FreeMarkerRegistrationback to summary
public FreeMarkerRegistration()
org.springframework.web.servlet.config.annotation back to summary

private Class ViewResolverRegistry.GroovyMarkupRegistration

extends UrlBasedViewResolverRegistration
Class Inheritance

Field Summary

Inherited from org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration:
viewResolver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration:
attributescachecacheLimitgetViewResolverprefixsuffixviewClassviewNames

Constructor Detail

GroovyMarkupRegistrationback to summary
public GroovyMarkupRegistration()
org.springframework.web.servlet.config.annotation back to summary

private Class ViewResolverRegistry.ScriptRegistration

extends UrlBasedViewResolverRegistration
Class Inheritance

Field Summary

Inherited from org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration:
viewResolver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration:
attributescachecacheLimitgetViewResolverprefixsuffixviewClassviewNames

Constructor Detail

ScriptRegistrationback to summary
public ScriptRegistration()