title: two DispatherServlets in one web.xml
body: <p>I write spring mvc application.</p>
  
  <p>I Have 2 controllers. I want handles it different instances of dispatcherservlet.</p>
  
  <p>How Can I make it?</p>
  
  <p>controller 1:</p>
  
  <pre><code>@Controller
  @RequestMapping("/controllerPath")
  public class MyController {
  
      @RequestMapping("/sayHello")
      public String sayHello(Model model){
          ...
      }
  
  }
  </code></pre>
  
  <p>controller 2:</p>
  
  <pre><code>@Controller
  @RequestMapping("/restControllerPath")
  public class RestController {
  
      @RequestMapping (value = "importantObject", method = RequestMethod.GET)
      @ResponseBody
      public  VeryImportantlClass getInformation(){
          ...
      }
  }
  </code></pre>
  
  <p>What I need to write in web.xml?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code> &lt;servlet&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
                    org.springframework.web.servlet.DispatcherServlet
          &lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;mvc-dispatcher-rest&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
                    org.springframework.web.servlet.DispatcherServlet
          &lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;controllerPath/**&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher-rest&lt;/servlet-name&gt;
          &lt;url-pattern&gt;restControllerPath/**&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I see </p>
  
  <pre><code>ava.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
      at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
      at java.util.concurrent.FutureTask.get(FutureTask.java:83)
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
      at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:684)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: org.apache.catalina.LifecycleException: A child container failed during start
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
      at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      ... 7 more
  29.10.2013 21:02:38 org.apache.catalina.startup.Catalina start
  SEVERE: Catalina.start: 
  org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:684)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
      at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      ... 7 more
  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
      at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      ... 9 more
  Caused by: org.apache.catalina.LifecycleException: A child container failed during start
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
      at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      ... 11 more
  </code></pre>
  
  <p>other trying:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher-rest&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/restControllerPath/**&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>the variant above - 404 </p>
  
  <p><strong>BUT</strong></p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher-rest&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>working way</p>