title: Spring MVC @RequestMapping not working
body: <p>I have a strange scenario in which my controller is not invoked unless I map the dispatcher servlet to /* in web.xml. I have defined a controller with a RequestMapping:</p>
  
  <pre><code>@Controller  
  public class UserController {
  
      @RequestMapping(value = "/rest/users", method = RequestMethod.GET)
      public ModelAndView getUsers(HttpServletRequest request) throws RestException {
        ...
      }  
  }
  </code></pre>
  
  <p>And an application context:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"&gt;
  
      &lt;context:component-scan base-package="com.test.rest.controller" /&gt; 
  </code></pre>
  
  <p>Finally this is mapped in web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;rest-servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/restContext.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rest-servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>This works as expected i.e. I can make requests to /rest/users. However if I change the web.xml mapping to:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;rest-servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I get an MVC error:</p>
  
  <blockquote>
    <p>WARN servlet.PageNotFound: No mapping found for HTTP request with URI
    [/rest/users] in DispatcherServlet with name 'rest-servlet'.</p>
  </blockquote>
  
  <p>It seems really strange because the error indicates that the request is being mapped to the dispatcher-servlet, yet the only thing that has changed is the servlet mapping. </p>
  
  <p>Has anyone else encountered this?</p>