类 ViewResolverRegistry
- java.lang.Object
- org.springframework.web.servlet.config.annotation.ViewResolverRegistry
public class ViewResolverRegistry extends Object
Assist with the configuration of a chain ofViewResolver
instances. This class is expected to be used viaWebMvcConfigurer.configureViewResolvers(org.springframework.web.servlet.config.annotation.ViewResolverRegistry)
.- 从以下版本开始:
- 4.1
- 作者:
- Sebastien Deleuze, Rossen Stoyanchev
构造器概要
构造器 构造器 说明 ViewResolverRegistry()
已过时。ViewResolverRegistry(ContentNegotiationManager contentNegotiationManager, ApplicationContext context)
Class constructor withContentNegotiationManager
andApplicationContext
.
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 void
beanName()
Register a bean name view resolver that interprets view names as the names ofView
beans.void
enableContentNegotiation(boolean useNotAcceptableStatus, View... defaultViews)
Enable use of aContentNegotiatingViewResolver
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).void
enableContentNegotiation(View... defaultViews)
Enable use of aContentNegotiatingViewResolver
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).UrlBasedViewResolverRegistration
freeMarker()
Register a FreeMarker view resolver with an empty default view name prefix and a default suffix of ".ftl".protected int
getOrder()
protected List<ViewResolver>
getViewResolvers()
UrlBasedViewResolverRegistration
groovy()
Register a Groovy markup view resolver with an empty default view name prefix and a default suffix of ".tpl".protected boolean
hasBeanOfType(Class<?> beanType)
已过时。boolean
hasRegistrations()
Whether any view resolvers have been registered.UrlBasedViewResolverRegistration
jsp()
Register JSP view resolver using a default view name prefix of "/WEB-INF/" and a default suffix of ".jsp".UrlBasedViewResolverRegistration
jsp(String prefix, String suffix)
Register JSP view resolver with the specified prefix and suffix.void
order(int order)
ViewResolver's registered through this registry are encapsulated in an instance ofViewResolverComposite
and follow the order of registration.UrlBasedViewResolverRegistration
scriptTemplate()
Register a script template view resolver with an empty default view name prefix and suffix.protected void
setApplicationContext(ApplicationContext applicationContext)
已过时。protected void
setContentNegotiationManager(ContentNegotiationManager contentNegotiationManager)
已过时。UrlBasedViewResolverRegistration
tiles()
Register Tiles 3.x view resolver.UrlBasedViewResolverRegistration
velocity()
已过时。as of Spring 4.3, in favor of FreeMarkervoid
viewResolver(ViewResolver viewResolver)
Register aViewResolver
bean instance.
构造器详细资料
ViewResolverRegistry
public ViewResolverRegistry(ContentNegotiationManager contentNegotiationManager, ApplicationContext context)
Class constructor withContentNegotiationManager
andApplicationContext
.- 从以下版本开始:
- 4.3.12
ViewResolverRegistry
@Deprecated public ViewResolverRegistry()
已过时。
方法详细资料
hasRegistrations
public boolean hasRegistrations()
Whether any view resolvers have been registered.
enableContentNegotiation
public void enableContentNegotiation(View... defaultViews)
Enable use of aContentNegotiatingViewResolver
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.
enableContentNegotiation
public void enableContentNegotiation(boolean useNotAcceptableStatus, View... defaultViews)
Enable use of aContentNegotiatingViewResolver
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.
jsp
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.
jsp
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.
tiles
public UrlBasedViewResolverRegistration tiles()
Register Tiles 3.x view resolver.Note that you must also configure Tiles by adding a
TilesConfigurer
bean.
freeMarker
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
FreeMarkerConfigurer
bean.
velocity
@Deprecated public UrlBasedViewResolverRegistration velocity()
已过时。as of Spring 4.3, in favor of FreeMarkerRegister Velocity view resolver with an empty default view name prefix and a default suffix of ".vm".Note that you must also configure Velocity by adding a
VelocityConfigurer
bean.
groovy
public UrlBasedViewResolverRegistration groovy()
Register a Groovy markup view resolver with an empty default view name prefix and a default suffix of ".tpl".
scriptTemplate
public UrlBasedViewResolverRegistration scriptTemplate()
Register a script template view resolver with an empty default view name prefix and suffix.- 从以下版本开始:
- 4.2
beanName
public void beanName()
Register a bean name view resolver that interprets view names as the names ofView
beans.
viewResolver
public void viewResolver(ViewResolver viewResolver)
Register aViewResolver
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.
order
public void order(int order)
ViewResolver's registered through this registry are encapsulated in an instance ofViewResolverComposite
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 configurationBy 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 toOrdered.HIGHEST_PRECEDENCE
.
getOrder
protected int getOrder()
getViewResolvers
protected List<ViewResolver> getViewResolvers()
hasBeanOfType
@Deprecated protected boolean hasBeanOfType(Class<?> beanType)
已过时。
setContentNegotiationManager
@Deprecated protected void setContentNegotiationManager(ContentNegotiationManager contentNegotiationManager)
已过时。
setApplicationContext
@Deprecated protected void setApplicationContext(ApplicationContext applicationContext)
已过时。