public abstract class AbstractDispatcherServletInitializer extends AbstractContextLoaderInitializer
WebApplicationInitializer
 implementations that register a DispatcherServlet in the servlet context.
 Concrete implementations are required to implement
 createServletApplicationContext(), as well as getServletMappings(),
 both of which get invoked from registerDispatcherServlet(ServletContext).
 Further customization can be achieved by overriding
 customizeRegistration(ServletRegistration.Dynamic).
 
Because this class extends from AbstractContextLoaderInitializer, concrete
 implementations are also required to implement AbstractContextLoaderInitializer.createRootApplicationContext()
 to set up a parent "root" application context. If a root context is
 not desired, implementations can simply return null in the
 createRootApplicationContext() implementation.
| Modifier and Type | Field and Description | 
|---|---|
| static String | DEFAULT_SERVLET_NAMEThe default servlet name. | 
logger| Constructor and Description | 
|---|
| AbstractDispatcherServletInitializer() | 
| Modifier and Type | Method and Description | 
|---|---|
| protected FrameworkServlet | createDispatcherServlet(WebApplicationContext servletAppContext)Create a  DispatcherServlet(or other kind ofFrameworkServlet-derived
 dispatcher) with the specifiedWebApplicationContext. | 
| protected abstract WebApplicationContext | createServletApplicationContext()Create a servlet application context to be provided to the  DispatcherServlet. | 
| protected void | customizeRegistration(ServletRegistration.Dynamic registration)Optionally perform further registration customization once
  registerDispatcherServlet(ServletContext)has completed. | 
| protected ApplicationContextInitializer<?>[] | getServletApplicationContextInitializers()Specify application context initializers to be applied to the servlet-specific
 application context that the  DispatcherServletis being created with. | 
| protected Filter[] | getServletFilters()Specify filters to add and map to the  DispatcherServlet. | 
| protected abstract String[] | getServletMappings()Specify the servlet mapping(s) for the  DispatcherServlet—
 for example"/","/app", etc. | 
| protected String | getServletName()Return the name under which the  DispatcherServletwill be registered. | 
| protected boolean | isAsyncSupported()A single place to control the  asyncSupportedflag for theDispatcherServletand all filters added viagetServletFilters(). | 
| void | onStartup(ServletContext servletContext)Configure the given  ServletContextwith any servlets, filters, listeners
 context-params and attributes necessary for initializing this web application. | 
| protected void | registerDispatcherServlet(ServletContext servletContext)Register a  DispatcherServletagainst the given servlet context. | 
| protected FilterRegistration.Dynamic | registerServletFilter(ServletContext servletContext,
                     Filter filter)Add the given filter to the ServletContext and map it to the
  DispatcherServletas follows:
 
 a default filter name is chosen based on its concrete type
 theasyncSupportedflag is set depending on the
 return value ofasyncSupporteda filter mapping is created with dispatcher typesREQUEST,FORWARD,INCLUDE, and conditionallyASYNCdepending
 on the return value ofasyncSupported | 
createRootApplicationContext, getRootApplicationContextInitializers, registerContextLoaderListenerpublic static final String DEFAULT_SERVLET_NAME
getServletName().public AbstractDispatcherServletInitializer()
public void onStartup(ServletContext servletContext) throws ServletException
WebApplicationInitializerServletContext with any servlets, filters, listeners
 context-params and attributes necessary for initializing this web application. See
 examples above.onStartup in interface WebApplicationInitializeronStartup in class AbstractContextLoaderInitializerservletContext - the ServletContext to initializeServletException - if any call against the given ServletContext
 throws a ServletExceptionprotected void registerDispatcherServlet(ServletContext servletContext)
DispatcherServlet against the given servlet context.
 This method will create a DispatcherServlet with the name returned by
 getServletName(), initializing it with the application context returned
 from createServletApplicationContext(), and mapping it to the patterns
 returned from getServletMappings().
 
Further customization can be achieved by overriding customizeRegistration(ServletRegistration.Dynamic) or
 createDispatcherServlet(WebApplicationContext).
servletContext - the context to register the servlet againstprotected String getServletName()
DispatcherServlet will be registered.
 Defaults to DEFAULT_SERVLET_NAME.protected abstract WebApplicationContext createServletApplicationContext()
DispatcherServlet.
 The returned context is delegated to Spring's
 DispatcherServlet.DispatcherServlet(WebApplicationContext). As such,
 it typically contains controllers, view resolvers, locale resolvers, and other
 web-related beans.
protected FrameworkServlet createDispatcherServlet(WebApplicationContext servletAppContext)
DispatcherServlet (or other kind of FrameworkServlet-derived
 dispatcher) with the specified WebApplicationContext.
 Note: This allows for any FrameworkServlet subclass as of 4.2.3.
 Previously, it insisted on returning a DispatcherServlet or subclass thereof.
protected ApplicationContextInitializer<?>[] getServletApplicationContextInitializers()
DispatcherServlet is being created with.protected abstract String[] getServletMappings()
DispatcherServlet —
 for example "/", "/app", etc.protected Filter[] getServletFilters()
DispatcherServlet.nullregisterServletFilter(ServletContext, Filter)protected FilterRegistration.Dynamic registerServletFilter(ServletContext servletContext, Filter filter)
DispatcherServlet as follows:
 asyncSupported flag is set depending on the
 return value of asyncSupported
 REQUEST,
 FORWARD, INCLUDE, and conditionally ASYNC depending
 on the return value of asyncSupported
 If the above defaults are not suitable or insufficient, override this
 method and register filters directly with the ServletContext.
servletContext - the servlet context to register filters withfilter - the filter to be registeredprotected boolean isAsyncSupported()
asyncSupported flag for the
 DispatcherServlet and all filters added via getServletFilters().
 The default value is "true".
protected void customizeRegistration(ServletRegistration.Dynamic registration)
registerDispatcherServlet(ServletContext) has completed.registration - the DispatcherServlet registration to be customizedregisterDispatcherServlet(ServletContext)