title: Spring MVC 3 : Ambiguous mapping found
body: <p>I am playing with spring MVC 3.1 and testing different features. I wanted to verify following statement taken from <a href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/bind/annotation/RequestMapping.html#value%28%29" rel="noreferrer">@RequestMapping#value doc</a></p>
  
  <pre><code>If you have a single default method (without explicit path mapping), then all requests without a more specific mapped method found will be dispatched to it. If you have multiple such default methods, then the method name will be taken into account for choosing between them
  </code></pre>
  
  <p>So I created following controller with multiple default handler methods.</p>
  
  <pre><code>@Controller
  @RequestMapping("/book")
  public class BookController {
  
      @RequestMapping
      public @ResponseBody String greet() {
          return "Hi Book!";
      }
  
      @RequestMapping
      public @ResponseBody String meet() {
          return "Nice to meet you Book!";
      }
  }
  </code></pre>
  
  <p>Here is web application context configuration</p>
  
  <pre><code>&lt;beans ....&gt;
  &lt;!-- Use @Component annotations for bean definitions --&gt;
    &lt;context:component-scan base-package="com.botreeconsulting.lms.web"/&gt;
  
    &lt;!-- Use @Controller annotations for MVC controller definitions --&gt;
    &lt;mvc:annotation-driven /&gt;
  
    &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
  
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
     &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>But it seems I messed up something as it is giving me following error at the time of deployment:</p>
  
  <pre><code>java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'bookController' bean method 
  public java.lang.String com.botreeconsulting.lms.web.BookController.meet()
  to {[/book],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'bookController' bean method
  public java.lang.String com.botreeconsulting.lms.web.BookController.greet() mapped.
  </code></pre>
  
  <p>Now the question is does this controller models what is written in the document? I feel that I didn't get it properly. Please guide me to model the controller to match the statement about multiple default handlers.</p>
  
  <p>Thanks, Amit</p>