类 XmlViewResolver
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.servlet.view.AbstractCachingViewResolver
- org.springframework.web.servlet.view.XmlViewResolver
- 所有已实现的接口:
Aware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ServletContextAware
,ViewResolver
public class XmlViewResolver extends AbstractCachingViewResolver implements Ordered, InitializingBean, DisposableBean
AViewResolver
implementation that uses bean definitions in a dedicated XML file for view definitions, specified by resource location. The file will typically be located in the WEB-INF directory; the default is "/WEB-INF/views.xml".This
ViewResolver
does not support internationalization at the level of its definition resources. ConsiderResourceBundleViewResolver
if you need to apply different view resources per locale.Note: This
ViewResolver
implements theOrdered
interface in order to allow for flexible participation inViewResolver
chaining. For example, some special views could be defined via thisViewResolver
(giving it 0 as "order" value), while all remaining views could be resolved by aUrlBasedViewResolver
.- 从以下版本开始:
- 18.06.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
ResourceLoader.getResource(java.lang.String)
,ResourceBundleViewResolver
,UrlBasedViewResolver
嵌套类概要
从类继承的嵌套类/接口 org.springframework.web.servlet.view.AbstractCachingViewResolver
AbstractCachingViewResolver.CacheFilter
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_LOCATION
Default if no other location is supplied.从类继承的字段 org.springframework.web.servlet.view.AbstractCachingViewResolver
DEFAULT_CACHE_LIMIT
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 XmlViewResolver()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Pre-initialize the factory from the XML file.void
destroy()
Close the view bean factory on context shutdown.protected Object
getCacheKey(String viewName, Locale locale)
This implementation returns just the view name, as XmlViewResolver doesn't support localized resolution.int
getOrder()
Get the order value of this object.protected BeanFactory
initFactory()
Initialize the view bean factory from the XML file.protected View
loadView(String viewName, Locale locale)
Subclasses must implement this method, building a View object for the specified view.void
setLocation(Resource location)
Set the location of the XML file that defines the view beans.void
setOrder(int order)
Specify the order value for this ViewResolver bean.从类继承的方法 org.springframework.web.servlet.view.AbstractCachingViewResolver
clearCache, createView, getCacheFilter, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, resolveViewName, setCache, setCacheFilter, setCacheLimit, setCacheUnresolved
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
字段详细资料
DEFAULT_LOCATION
public static final String DEFAULT_LOCATION
Default if no other location is supplied.- 另请参阅:
- 常量字段值
构造器详细资料
XmlViewResolver
public XmlViewResolver()
方法详细资料
setLocation
public void setLocation(Resource location)
Set the location of the XML file that defines the view beans.The default is "/WEB-INF/views.xml".
- 参数:
location
- the location of the XML file.
setOrder
public void setOrder(int order)
Specify the order value for this ViewResolver bean.The default value is
Ordered.LOWEST_PRECEDENCE
, meaning non-ordered.- 另请参阅:
Ordered.getOrder()
getOrder
public int getOrder()
从接口复制的说明: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.
- 指定者:
getOrder
在接口中Ordered
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
afterPropertiesSet
public void afterPropertiesSet() throws BeansException
Pre-initialize the factory from the XML file. Only effective if caching is enabled.- 指定者:
afterPropertiesSet
在接口中InitializingBean
- 抛出:
BeansException
getCacheKey
protected Object getCacheKey(String viewName, Locale locale)
This implementation returns just the view name, as XmlViewResolver doesn't support localized resolution.
loadView
protected View loadView(String viewName, Locale locale) throws BeansException
从类复制的说明:AbstractCachingViewResolver
Subclasses must implement this method, building a View object for the specified view. The returned View objects will be cached by this ViewResolver base class.Subclasses are not forced to support internationalization: A subclass that does not may simply ignore the locale parameter.
- 指定者:
loadView
在类中AbstractCachingViewResolver
- 参数:
viewName
- the name of the view to retrievelocale
- the Locale to retrieve the view for- 返回:
- the View instance, or
null
if not found (optional, to allow for ViewResolver chaining) - 抛出:
BeansException
- 另请参阅:
AbstractCachingViewResolver.resolveViewName(java.lang.String, java.util.Locale)
initFactory
protected BeanFactory initFactory() throws BeansException
Initialize the view bean factory from the XML file. Synchronized because of access by parallel threads.- 抛出:
BeansException
- in case of initialization errors
destroy
public void destroy() throws BeansException
Close the view bean factory on context shutdown.- 指定者:
destroy
在接口中DisposableBean
- 抛出:
BeansException