类 AbstractAnnotationConfigDispatcherServletInitializer
- java.lang.Object
- org.springframework.web.context.AbstractContextLoaderInitializer
- org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
- org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer
- 所有已实现的接口:
WebApplicationInitializer
public abstract class AbstractAnnotationConfigDispatcherServletInitializer extends AbstractDispatcherServletInitializer
Base class forWebApplicationInitializer
implementations that register aDispatcherServlet
configured with annotated classes, e.g. Spring's@Configuration
classes.Concrete implementations are required to implement
getRootConfigClasses()
andgetServletConfigClasses()
as well asAbstractDispatcherServletInitializer.getServletMappings()
. Further template and customization methods are provided byAbstractDispatcherServletInitializer
.This is the preferred approach for applications that use Java-based Spring configuration.
- 从以下版本开始:
- 3.2
- 作者:
- Arjen Poutsma, Chris Beams
字段概要
从类继承的字段 org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
DEFAULT_SERVLET_NAME
从类继承的字段 org.springframework.web.context.AbstractContextLoaderInitializer
logger
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected WebApplicationContext
createRootApplicationContext()
Create the "root" application context to be provided to theContextLoaderListener
.protected WebApplicationContext
createServletApplicationContext()
Create a servlet application context to be provided to theDispatcherServlet
.protected abstract Class<?>[]
getRootConfigClasses()
protected abstract Class<?>[]
getServletConfigClasses()
Specify@Configuration
and/or@Component
classes to be provided to the dispatcher servlet application context.从类继承的方法 org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
createDispatcherServlet, customizeRegistration, getServletApplicationContextInitializers, getServletFilters, getServletMappings, getServletName, isAsyncSupported, onStartup, registerDispatcherServlet, registerServletFilter
从类继承的方法 org.springframework.web.context.AbstractContextLoaderInitializer
getRootApplicationContextInitializers, registerContextLoaderListener
构造器详细资料
AbstractAnnotationConfigDispatcherServletInitializer
public AbstractAnnotationConfigDispatcherServletInitializer()
方法详细资料
createRootApplicationContext
protected WebApplicationContext createRootApplicationContext()
Create the "root" application context to be provided to theContextLoaderListener
.The returned context is delegated to
ContextLoaderListener(WebApplicationContext)
and will be established as the parent context for anyDispatcherServlet
application contexts. As such, it typically contains middle-tier services, data sources, etc.This implementation creates an
AnnotationConfigWebApplicationContext
, providing it the annotated classes returned bygetRootConfigClasses()
. Returnsnull
ifgetRootConfigClasses()
returnsnull
.- 指定者:
createRootApplicationContext
在类中AbstractContextLoaderInitializer
- 返回:
- the root application context, or
null
if a root context is not desired - 另请参阅:
AbstractDispatcherServletInitializer
createServletApplicationContext
protected WebApplicationContext createServletApplicationContext()
Create a servlet application context to be provided to theDispatcherServlet
.The returned context is delegated to Spring's
DispatcherServlet(WebApplicationContext)
. As such, it typically contains controllers, view resolvers, locale resolvers, and other web-related beans.This implementation creates an
AnnotationConfigWebApplicationContext
, providing it the annotated classes returned bygetServletConfigClasses()
.
getRootConfigClasses
protected abstract Class<?>[] getRootConfigClasses()
- 返回:
- the configuration classes for the root application context, or
null
if creation and registration of a root context is not desired
getServletConfigClasses
protected abstract Class<?>[] getServletConfigClasses()
Specify@Configuration
and/or@Component
classes to be provided to the dispatcher servlet application context.- 返回:
- the configuration classes for the dispatcher servlet application context or
null
if all configuration is specified through root config classes.