参见:http://www.boyunjian.com/javadoc/org.springframework/spring-webmvc/4.0.5.RELEASE/_/org/springframework/web/servlet/view/InternalResourceViewResolver.html
类 InternalResourceViewResolver
- java.lang.Object
-
- WebApplicationObjectSupport
-
- org.springframework.web.servlet.view.AbstractCachingViewResolver
-
- org.springframework.web.servlet.view.UrlBasedViewResolver
-
- org.springframework.web.servlet.view.InternalResourceViewResolver
-
- 所有已实现的接口:
- ViewResolver
public class InternalResourceViewResolver extends UrlBasedViewResolver
Convenient subclass of
UrlBasedViewResolver
that supports
InternalResourceView
(i.e. Servlets and JSPs) and subclasses such asJstlView
.The view class for all views generated by this resolver can be specified via
UrlBasedViewResolver.setViewClass(java.lang.Class<?>)
. See
UrlBasedViewResolver
's javadoc for details. The default is
InternalResourceView
, or
JstlView
if the JSTL API is present.BTW, it's good practice to put JSP files that just serve as views under WEB-INF, to hide them from direct access (e.g. via a manually entered URL). Only controllers will be able to access them then.(顺便说一下,将JSP文件放入WEB-INF下是个好习惯,把它们对直接存取隐藏掉。仅只有控制器可以获取它们。)
-
Note: When chaining ViewResolvers, an InternalResourceViewResolver always needs to be last, as it will attempt to resolve any view name, no matter whether the underlying resource actually exists.
-
-
字段概要
-
从类继承的字段 org.springframework.web.servlet.view.UrlBasedViewResolver
-
从类继承的字段 org.springframework.web.servlet.view.AbstractCachingViewResolver
-
-
构造器概要
构造器 构造器和说明 InternalResourceViewResolver()
Sets the default
view class
to
requiredViewClass()
: by default
InternalResourceView
, or
JstlView
if the JSTL API is present.
-
方法概要
方法 限定符和类型 方法和说明 protected
AbstractUrlBasedViewbuildView(java.lang.String viewName)
Creates a new View instance of the specified view class and configures it.protected java.lang.Class<?>
requiredViewClass()
This resolver requires
InternalResourceView
.void
setAlwaysInclude(boolean alwaysInclude)
Specify whether to always include the view rather than forward to it.void
setExposeContextBeansAsAttributes(boolean exposeContextBeansAsAttributes)
Set whether to make all Spring beans in the application context accessible as request attributes, through lazy checking once an attribute gets accessed.void
setExposedContextBeanNames(java.lang.String[] exposedContextBeanNames)
Specify the names of beans in the context which are supposed to be exposed.-
从类继承的方法 org.springframework.web.servlet.view.UrlBasedViewResolver
canHandle,createView,
getAttributesMap,
getCacheKey,
getContentType,
getOrder,
getPrefix,
getRequestContextAttribute,
getSuffix,
getViewClass,
getViewNames,
initApplicationContext,
isRedirectContextRelative,
isRedirectHttp10Compatible,
loadView,
setAttributes,
setAttributesMap,
setContentType,
setExposePathVariables,
setOrder,
setPrefix,
setRedirectContextRelative,
setRedirectHttp10Compatible,
setRequestContextAttribute,
setSuffix,
setViewClass,
setViewNames
-
从类继承的方法 org.springframework.web.servlet.view.AbstractCachingViewResolver
clearCache,getCacheLimit,
isCache,
isCacheUnresolved,
removeFromCache,
resolveViewName,
setCache,
setCacheLimit,
setCacheUnresolved
-
-
-
-
构造器详细资料
-
InternalResourceViewResolver
public InternalResourceViewResolver()
Sets the default
view class
to
requiredViewClass()
: by default
InternalResourceView
, or
JstlView
if the JSTL API is present.
-
-
方法详细资料
-
requiredViewClass
protected java.lang.Class<?> requiredViewClass()
This resolver requires
InternalResourceView
.- 覆盖:
requiredViewClass
在类中UrlBasedViewResolver
- 另请参阅:
AbstractUrlBasedView
-
setAlwaysInclude
public void setAlwaysInclude(boolean alwaysInclude)
Specify whether to always include the view rather than forward to it.Default is "false". Switch this flag on to enforce the use of a Servlet include, even if a forward would be possible.
-
setExposeContextBeansAsAttributes
public void setExposeContextBeansAsAttributes(boolean exposeContextBeansAsAttributes)
Set whether to make all Spring beans in the application context accessible as request attributes, through lazy checking once an attribute gets accessed.This will make all such beans accessible in plain
${...}
expressions in a JSP 2.0 page, as well as in JSTL'sc:out
value expressions.Default is "false".
-
setExposedContextBeanNames
public void setExposedContextBeanNames(java.lang.String[] exposedContextBeanNames)
Specify the names of beans in the context which are supposed to be exposed. If this is non-null, only the specified beans are eligible for exposure as attributes.
-
buildView
protected AbstractUrlBasedView buildView(java.lang.String viewName) throws java.lang.Exception
从类复制的说明:UrlBasedViewResolver
Creates a new View instance of the specified view class and configures it. Doesnot perform any lookup for pre-defined View instances.Spring lifecycle methods as defined by the bean container do not have to be called here; those will be applied by the
loadView
method after this method returns.Subclasses will typically call
super.buildView(viewName)
first, before setting further properties themselves.loadView
will then apply Spring lifecycle methods at the end of this process.- 覆盖:
buildView
在类中UrlBasedViewResolver
- 参数:
viewName
- the name of the view to build- 返回:
- the View instance
- 抛出:
java.lang.Exception
- if the view couldn't be resolved- 另请参阅:
UrlBasedViewResolver.loadView(String,
java.util.Locale)
-
-