title: Spring set default PathVariable
body: <p>I want to pass in my parameters to my web service in the format:</p>
  
  <p><a href="http://.../greetings/neil/1" rel="noreferrer">http://.../greetings/neil/1</a></p>
  
  <p>Rather than</p>
  
  <p><a href="http://.../greetings?name=neil&amp;id=1" rel="noreferrer">http://.../greetings?name=neil&amp;id=1</a></p>
  
  <p>So I changed my code from (note, I've only included the first parameter in the code):</p>
  
  <pre><code>@RequestMapping("/greeting")
  public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
      return new Greeting(counter.incrementAndGet(),
                          String.format(template, name));
  }
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>@RequestMapping
  public Greeting greeting(@PathVariable String name) {
      return new Greeting(counter.incrementAndGet(),
                          String.format(template, name));
  }
  </code></pre>
  
  <p>which works, however I do not know how to add default values to @PathVariable so that for example:</p>
  
  <p><a href="http://.../greetings/" rel="noreferrer">http://.../greetings/</a></p>
  
  <p><a href="http://.../greetings/neil/" rel="noreferrer">http://.../greetings/neil/</a></p>
  
  <p>would work as it does with query parameters.</p>
  
  <p>How do I do this? I thought maybe it would pass null, but it just generates a page error. </p>
  
  <p>I guess the answer might be to add multiple overloads, but that sounds a bit messy.</p>
  
  <p>thanks.</p>
  
  <p>thanks.</p>