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
A ViewResolver that delegates to others.
Since:
4.1
Author:
Sebastien Deleuze, Rossen Stoyanchev
  • Constructor Details

    • ViewResolverComposite

      public ViewResolverComposite()
  • Method Details

    • 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: Ordered
      Get 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-startup values).

      Same order values will result in arbitrary sort positions for the affected objects.

      Specified by:
      getOrder in interface Ordered
      Returns:
      the order value
      See Also:
    • setApplicationContext

      public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
      Description copied from interface: ApplicationContextAware
      Set 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 after ResourceLoaderAware.setResourceLoader(ResourceLoader), ApplicationEventPublisherAware.setApplicationEventPublisher(ApplicationEventPublisher) and MessageSourceAware, if applicable.

      Specified by:
      setApplicationContext in interface ApplicationContextAware
      Parameters:
      applicationContext - the ApplicationContext object to be used by this object
      Throws:
      BeansException - if thrown by application context methods
      See Also:
    • setServletContext

      public void setServletContext(jakarta.servlet.ServletContext servletContext)
      Description copied from interface: ServletContextAware
      Set the ServletContext that this object runs in.

      Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.

      Specified by:
      setServletContext in interface ServletContextAware
      Parameters:
      servletContext - the ServletContext object to be used by this object
      See Also:
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Description copied from interface: InitializingBean
      Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

      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:
      afterPropertiesSet in interface InitializingBean
      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 @Nullable View resolveViewName(String viewName, Locale locale) throws Exception
      Description copied from interface: ViewResolver
      Resolve the given view by name.

      Note: To allow for ViewResolver chaining, a ViewResolver should return null if 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 return null (rather throwing an exception when View creation failed).

      Specified by:
      resolveViewName in interface ViewResolver
      Parameters:
      viewName - name of the view to resolve
      locale - the Locale in which to resolve the view. ViewResolvers that support internationalization should respect this.
      Returns:
      the View object, or null if 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)