title: Spring MVC - No mapping found for request URI
body: <p>There are many questions relating to this error on Stack&nbsp;Overflow, and I've tried the solutions to the most pertinent ones without success. Here is my problem.</p>
  
  <p>I am trying to map this request: <code>/user/{userId}</code> where <code>userId</code> is a String. I am able to handle GET requests to <code>/user</code> with the following annotated class and <a href="http://en.wikipedia.org/wiki/Spring_Framework" rel="nofollow">Spring</a> configuration:</p>
  
  <p><em>UserController.java</em></p>
  
  <pre><code>@Controller
  @RequestMapping("/user")
  public class UserController {
      private static final Logger log = Logger.getLogger(UserController.class.getName());
  
      @RequestMapping(method=RequestMethod.GET)
      public @ResponseBody String info() {
          log.debug("mapping succeeded!");
          return "&lt;H1&gt;foo&lt;/H1&gt;";
      }
  }
  </code></pre>
  
  <p><em>web/WEB-INF/user-servlet.xml</em></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:p="http://www.springframework.org/schema/p"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
      &lt;context:component-scan base-package="com.example"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><em>web.xml</em></p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;user&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;user&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/user/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Then when I request <code>/user</code></p>
  
  <pre><code>2011-01-14 15:47:41,942 DEBUG [com.example.rest.UserController] (http-11080-1) mapping succeeded!
  </code></pre>
  
  <p>Now to do something interesting. I change my code to the following:</p>
  
  <pre><code>@Controller
  @RequestMapping("/user")
  public class UserController {
      private static final Logger log = Logger.getLogger(UserController.class.getName());
  
      @RequestMapping(value="/{userId}", method=RequestMethod.GET)
      public @ResponseBody String info(@PathVariable String userId) {
          log.debug("mapping succeeded! userId=" + userId);
          return "&lt;H1&gt;foo&lt;/H1&gt;";
      }
  }
  </code></pre>
  
  <p>I have the dreaded <code>No mapping found...</code></p>
  
  <pre><code>(main) Pre-instantiating singletons in     org.springframework.beans.factory.support.DefaultListableBeanFactory@36598d00: defining beans     [userController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor]; root of factory hierarchy
  (main) instantiating UserController
  (main) Mapped URL path [/user/*] onto handler 'userController'
  (main) Mapped URL path [/user/*.*] onto handler 'userController'
  (main) Mapped URL path [/user/*/] onto handler 'userController'
  
  ...
  
  (http-11080-1) No mapping found for HTTP request with URI [/user] in DispatcherServlet with name 'user'
  (http-11080-1) No mapping found for HTTP request with URI [/user/foo] in DispatcherServlet with name 'user'
  (http-11080-1) No mapping found for HTTP request with URI [/user/] in DispatcherServlet with name 'user'
  </code></pre>
  
  <p>What am I doing wrong?</p>