public class BeanNameViewResolver extends org.springframework.web.context.support.WebApplicationObjectSupport implements ViewResolver, org.springframework.core.Ordered
This resolver can be handy for small applications, keeping all definitions ranging from controllers to views in the same place. For normal applications, XmlViewResolver will be the better choice, as it separates the XML view bean definitions into a dedicated views file. View beans should virtually never have references to any other application beans - such a separation will make this clear.
This ViewResolver does not support internationalization. Conside ResourceBundleViewResolver if you need to apply different view resources per locale.
Note: This ViewResolver implements the Ordered interface 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.
XmlViewResolver
,
ResourceBundleViewResolver
,
UrlBasedViewResolver
Constructor and Description |
---|
BeanNameViewResolver() |
Modifier and Type | Method and Description |
---|---|
int |
getOrder() |
View |
resolveViewName(String viewName,
Locale locale)
Resolve the given view by name.
|
void |
setOrder(int order) |
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
public void setOrder(int order)
public int getOrder()
getOrder
in interface org.springframework.core.Ordered
public View resolveViewName(String viewName, Locale locale) throws org.springframework.beans.BeansException
ViewResolver
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).
resolveViewName
in interface ViewResolver
viewName
- name of the view to resolvelocale
- Locale in which to resolve the view.
ViewResolvers that support internationalization should respect this.null
if not found
(optional, to allow for ViewResolver chaining)org.springframework.beans.BeansException