title: Spring MVC - Multiple submit button to a Form
body: <p>I am trying to have 2 submit buttons post to a form, with each button action mapped to different controllers. Here are my mappings</p>
  
  <pre><code>@RequestMapping(value="/save", method=RequestMethod.POST, params="save")
  @RequestMapping(value="/save", method=RequestMethod.POST, params="renew")
  </code></pre>
  
  <p>And my submit buttons look like these - </p>
  
  <pre><code>&lt;input type="submit" name="save" class="button" value="Save" /&gt;
  &lt;input type="submit" name="renew" class="button" value="Renew" /&gt;
  </code></pre>
  
  <p>As you can see from my mapping, I am relying on the use of params to differentiate what button was clicked on. The problem is that it works 90% of the time but sometimes I get the exception below - </p>
  
  <pre><code>java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8090/myapp/save': {public java.lang.String com.myapp.SaveController.save(MyEntity,javax.servlet.http.HttpSession), public java.lang.String com.myapp.SaveController.saveAndRenew(MyEntity,javax.servlet.http.HttpSession)}
  org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:248)
  org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:194)
  </code></pre>
  
  <p>Strangely, when this happens and I re-submit the page, everything works fine afterwards. Is there a better way to achieve what I'm trying to do ?</p>
  
  <p>Thanks!</p>