public class BeanNameViewResolver extends WebApplicationObjectSupport implements ViewResolver, Ordered
ViewResolverthat interprets a view name as a bean name in the current application context, i.e. typically in the XML file of the executing
This resolver can be handy for small applications, keeping all definitions
ranging from controllers to views in the same place. For larger applications,
XmlViewResolver will be the better choice, as it separates the XML
view bean definitions into a dedicated views file.
ViewResolver implements the
in order to allow for flexible participation in
For example, some special views could be defined via this
(giving it 0 as "order" value), while all remaining views could be resolved by
|Constructor and Description|
|Modifier and Type||Method and Description|
Get the order value of this object.
Resolve the given view by name.
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
public void setOrder(int order)
public int getOrder()
Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet
Same order values will result in arbitrary sort positions for the affected objects.
@Nullable public View resolveViewName(String viewName, Locale locale) throws BeansException
Note: To allow for ViewResolver chaining, a ViewResolver should
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
(rather throwing an exception when View creation failed).
viewName- name of the view to resolve
locale- Locale in which to resolve the view. ViewResolvers that support internationalization should respect this.
nullif not found (optional, to allow for ViewResolver chaining)