Class ViewResolverComposite
- java.lang.Object
- org.springframework.web.servlet.view.ViewResolverComposite
- All Implemented Interfaces:
Aware,InitializingBean,ApplicationContextAware,Ordered,ServletContextAware,ViewResolver
public class ViewResolverComposite extends Object implements ViewResolver, Ordered, InitializingBean, ApplicationContextAware, ServletContextAware
AViewResolverthat delegates to others.- Since:
- 4.1
- Author:
- Sebastien Deleuze, Rossen Stoyanchev
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor Summary
Constructors Constructor Description ViewResolverComposite()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.intgetOrder()Get the order value of this object.List<ViewResolver>getViewResolvers()Return the list of view viewResolvers to delegate to.ViewresolveViewName(String viewName, Locale locale)Resolve the given view by name.voidsetApplicationContext(ApplicationContext applicationContext)Set the ApplicationContext that this object runs in.voidsetOrder(int order)voidsetServletContext(ServletContext servletContext)Set theServletContextthat this object runs in.voidsetViewResolvers(List<ViewResolver> viewResolvers)Set the list of view viewResolvers to delegate to.
Constructor Detail
ViewResolverComposite
public ViewResolverComposite()
Method Detail
setViewResolvers
public void setViewResolvers(List<ViewResolver> viewResolvers)
Set the list of view viewResolvers to delegate to.
getViewResolvers
public List<ViewResolver> getViewResolvers()
Return the list of view viewResolvers to delegate to.
setOrder
public void setOrder(int order)
getOrder
public int getOrder()
Description copied from interface:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrderin interfaceOrdered- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE,Ordered.LOWEST_PRECEDENCE
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
Description copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
setApplicationContextin interfaceApplicationContextAware- Parameters:
applicationContext- the ApplicationContext object to be used by this object- Throws:
ApplicationContextException- in case of context initialization errorsBeansException- if thrown by application context methods- See Also:
BeanInitializationException
setServletContext
public void setServletContext(ServletContext servletContext)
Description copied from interface:ServletContextAwareSet theServletContextthat this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSetor a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext.- Specified by:
setServletContextin interfaceServletContextAware- Parameters:
servletContext- ServletContext object to be used by this object- See Also:
InitializingBean.afterPropertiesSet(),ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
afterPropertiesSet
public void afterPropertiesSet() throws Exception
Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
resolveViewName
public View resolveViewName(String viewName, Locale locale) throws Exception
Description copied from interface:ViewResolverResolve the given view by name.Note: To allow for ViewResolver chaining, a ViewResolver should return
nullif a view with the given name is not defined in it. However, this is not required: Some ViewResolvers will always attempt to build View objects with the given name, unable to returnnull(rather throwing an exception when View creation failed).- Specified by:
resolveViewNamein interfaceViewResolver- Parameters:
viewName- name of the view to resolvelocale- Locale in which to resolve the view. ViewResolvers that support internationalization should respect this.- Returns:
- the View object, or
nullif not found (optional, to allow for ViewResolver chaining) - Throws:
Exception- if the view cannot be resolved (typically in case of problems creating an actual View object)