title: Spring Web MVC: Use same request mapping for request parameter and path variable
body: <p>Is there a way to express that my Spring Web MVC controller method should be matched either by a request handing in a ID as part of the URI path ...</p>
  
  <pre><code>@RequestMapping(method=RequestMethod.GET, value="campaigns/{id}")
  public String getCampaignDetails(Model model, @PathVariable("id") Long id) {
  </code></pre>
  
  <p>... or if the client sends in the ID as a HTTP request parameter in the style ...</p>
  
  <pre><code>@RequestMapping(method=RequestMethod.GET, value="campaigns")
  public String getCampaignDetails(Model model, @RequestParam("id") Long id) {
  </code></pre>
  
  <p>This seems to me a quite common real-world URL scheme where I don't want to add duplicate code, but I wasn't able to find an answer yet.  Any advice highly welcome. </p>
  
  <p><strong>EDIT:</strong> It turns out that there seems currently <em>(with Spring MVC &lt;= 3.0)</em> no way to achieve this, see discussion inside Javi's answer.</p>