title: How does Tomcat exactly bootstrap the app without web.xml?
body: <p>I'm wondering how does <code>Tomcat</code> bootstrap my app on Spring MVC? </p>
  
  <p>I have an initializer:</p>
  
  <pre><code>public class AppInitializer implements WebApplicationInitializer {
      @Override
      public void onStartup(ServletContext container) {
          AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
          rootCtx.register(AppConfig.class);
          container.addListener(new ContextLoaderListener(rootCtx));
          AnnotationConfigWebApplicationContext dispatcherCtx = new AnnotationConfigWebApplicationContext();
          dispatcherCtx.register(FreeMarkerWebConfig.class);
          ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherCtx));
          dispatcher.setLoadOnStartup(1);
          dispatcher.addMapping("/");
      }
  }
  </code></pre>
  
  <p>I know why we need <code>web.xml</code> and how <code>Tomcat</code> uses it to bootstrap the app. But I don't understand how does <code>Tomcat</code> know which servlet it should use to bootstrap the application if there are no <code>xml</code> files, but only <code>AppAppInitializer</code>?</p>
  
  <p><em>Dependencies</em></p>
  
  <pre><code>&lt;!-- spring mvc --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
      &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
      &lt;version&gt;4.2.1.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;!-- servlet --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
      &lt;version&gt;3.0.1&lt;/version&gt;
  &lt;/dependency&gt;
  
  ...
  </code></pre>
  
  <p>I found this class in Spring core <code>SpringServletContainerInitializer</code>. Is it correct that <code>Tomcat</code> uses it to bootstrap my app?</p>
  
  <p><a href="http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContainerInitializer.html?is-external=true" rel="noreferrer">http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContainerInitializer.html?is-external=true</a></p>