title: How DefaultAnnotationHandlerMapping works
body: <p>I am confused about the way the DefaultAnnotationHandlerMapping works.</p>
  
  <p>In my web.xml I have</p>
  
  <pre><code> &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/somePath/someWork&lt;/url-pattern&gt;
  
      &lt;url-pattern&gt;/users&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/user/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;  
  </code></pre>
  
  <p>I have the controller like this,</p>
  
  <pre><code>   @RequestMapping(value="/user/adduser", method={RequestMethod.POST})
      public void addAdmin(@ModelAttribute("myData") myData data) {
  
          System.out.println("We reached adduser controller");
  
      }
  </code></pre>
  
  <p>And in the jsp file i have </p>
  
  <pre><code>&lt;form:form id="adduser" method="post" action="/user/adduser" commandName="myData"&gt;
  </code></pre>
  
  <p>This does not work. I get the error no handler mapping found for "/adduser" and 404 for the page "/user/adduser"</p>
  
  <p>But in the .xml file if i mention</p>
  
  <pre><code>  &lt;url-pattern&gt;/user/adduser&lt;/url-pattern&gt;
  </code></pre>
  
  <p>it works, or if i make the controller like,</p>
  
  <pre><code>  @RequestMapping(value="/adduser", method={RequestMethod.POST})
  </code></pre>
  
  <p>also works. When submitting the page it reaches the correct controller.</p>
  
  <p>I am now confused the way the @ReuqestMapping works. When a request comes like "/user/adduser" from where it will start looking for the right class and the right method?</p>