类 WebApplicationObjectSupport
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- 所有已实现的接口:
Aware
,ApplicationContextAware
,ServletContextAware
- 直接已知子类:
AbstractCachingViewResolver
,AbstractHandlerMapping
,AbstractView
,BeanNameViewResolver
,ContentNegotiatingViewResolver
,ServerEndpointExporter
,WebContentGenerator
public abstract class WebApplicationObjectSupport extends ApplicationObjectSupport implements ServletContextAware
Convenient superclass for application objects running in aWebApplicationContext
. ProvidesgetWebApplicationContext()
,getServletContext()
, andgetTempDir()
accessors.Note: It is generally recommended to use individual callback interfaces for the actual callbacks needed. This broad base class is primarily intended for use within the framework, in case of
ServletContext
access etc typically being needed.- 从以下版本开始:
- 28.08.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
SpringBeanAutowiringSupport
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
构造器概要
构造器 构造器 说明 WebApplicationObjectSupport()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected ServletContext
getServletContext()
Return the current ServletContext.protected File
getTempDir()
Return the temporary directory for the current web application, as provided by the servlet container.protected WebApplicationContext
getWebApplicationContext()
Return the current application context as WebApplicationContext.protected void
initApplicationContext(ApplicationContext context)
CallsinitServletContext(javax.servlet.ServletContext)
if the given ApplicationContext is aWebApplicationContext
.protected void
initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.protected boolean
isContextRequired()
Overrides the base class behavior to enforce running in an ApplicationContext.void
setServletContext(ServletContext servletContext)
Set theServletContext
that this object runs in.从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
构造器详细资料
WebApplicationObjectSupport
public WebApplicationObjectSupport()
方法详细资料
setServletContext
public final void setServletContext(ServletContext servletContext)
从接口复制的说明:ServletContextAware
Set theServletContext
that this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext
.- 指定者:
setServletContext
在接口中ServletContextAware
- 参数:
servletContext
- ServletContext object to be used by this object- 另请参阅:
InitializingBean.afterPropertiesSet()
,ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
isContextRequired
protected boolean isContextRequired()
Overrides the base class behavior to enforce running in an ApplicationContext. All accessors will throw IllegalStateException if not running in a context.
initApplicationContext
protected void initApplicationContext(ApplicationContext context)
CallsinitServletContext(javax.servlet.ServletContext)
if the given ApplicationContext is aWebApplicationContext
.- 覆盖:
initApplicationContext
在类中ApplicationObjectSupport
- 参数:
context
- the containing ApplicationContext- 另请参阅:
ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)
initServletContext
protected void initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.The default implementation is empty. Called by
initApplicationContext(org.springframework.context.ApplicationContext)
as well assetServletContext(javax.servlet.ServletContext)
.- 参数:
servletContext
- the ServletContext that this application object runs in (nevernull
)
getWebApplicationContext
protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException
Return the current application context as WebApplicationContext.NOTE: Only use this if you actually need to access WebApplicationContext-specific functionality. Preferably use
getApplicationContext()
orgetServletContext()
else, to be able to run in non-WebApplicationContext environments as well.- 抛出:
IllegalStateException
- if not running in a WebApplicationContext- 另请参阅:
ApplicationObjectSupport.getApplicationContext()
getServletContext
protected final ServletContext getServletContext() throws IllegalStateException
Return the current ServletContext.- 抛出:
IllegalStateException
- if not running within a ServletContext
getTempDir
protected final File getTempDir() throws IllegalStateException
Return the temporary directory for the current web application, as provided by the servlet container.- 返回:
- the File representing the temporary directory
- 抛出:
IllegalStateException
- if not running within a ServletContext- 另请参阅:
WebUtils.getTempDir(javax.servlet.ServletContext)