Top Description Fields Constructors Methods
org.springframework.web.servlet.view

public Class BeanNameViewResolver

extends WebApplicationObjectSupport
implements ViewResolver, Ordered
Class Inheritance
All Implemented Interfaces
org.springframework.core.Ordered, org.springframework.web.servlet.ViewResolver
Imports
java.util.Locale, org.springframework.beans.BeansException, org.springframework.context.ApplicationContext, org.springframework.core.Ordered, org.springframework.lang.Nullable, org.springframework.web.context.support.WebApplicationObjectSupport, org.springframework.web.servlet.View, .ViewResolver

A simple implementation of org.springframework.web.servlet.ViewResolver that interprets a view name as a bean name in the current application context, i.e. typically in the XML file of the executing DispatcherServlet or in a corresponding configuration class.

Note

This ViewResolver implements the Ordered interface in order to allow for flexible participation in ViewResolver chaining. For example, some special views could be defined via this ViewResolver (giving it 0 as "order" value), while all remaining views could be resolved by a UrlBasedViewResolver.

Author
Juergen Hoeller
Since
18.06.2003
See Also
UrlBasedViewResolver

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.

public View
resolveViewName(String
name of the view to resolve
viewName
,
Locale
the Locale in which to resolve the view. ViewResolvers that support internationalization should respect this.
locale
)

Implements org.springframework.web.servlet.ViewResolver.resolveViewName.

Resolve the given view by name.

public void
setOrder(int order)

Specify the order value for this ViewResolver bean.

Inherited from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContextgetTempDirgetWebApplicationContextinitApplicationContextinitServletContextisContextRequiredsetServletContext

Field Detail

orderback to summary
private int order

Constructor Detail

BeanNameViewResolverback to summary
public BeanNameViewResolver()

Method Detail

getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

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.

Returns:int

the order value

Annotations
@Override
resolveViewNameback to summary
public View resolveViewName(String viewName, Locale locale) throws BeansException

Implements org.springframework.web.servlet.ViewResolver.resolveViewName.

Doc from org.springframework.web.servlet.ViewResolver.resolveViewName.

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).

Parameters
viewName:String

name of the view to resolve

locale:Locale

the Locale in which to resolve the view. ViewResolvers that support internationalization should respect this.

Returns:View

the View object, or null if not found (optional, to allow for ViewResolver chaining)

Annotations
@Override
@Nullable
setOrderback to summary
public void setOrder(int order)

Specify the order value for this ViewResolver bean.

The default value is Ordered.LOWEST_PRECEDENCE, meaning non-ordered.

See Also
org.springframework.core.Ordered#getOrder()