title: With Spring can I make an optional path variable?
body: <p>With Spring 3.0, can I have an optional path variable?</p>
  
  <p>For example</p>
  
  <pre><code>@RequestMapping(value = "/json/{type}", method = RequestMethod.GET)
  public @ResponseBody TestBean testAjax(
          HttpServletRequest req,
          @PathVariable String type,
          @RequestParam("track") String track) {
      return new TestBean();
  }
  </code></pre>
  
  <p>Here I would like <code>/json/abc</code> or <code>/json</code> to call the same method. <br/>
  One obvious workaround declare <code>type</code> as a request parameter: </p>
  
  <pre><code>@RequestMapping(value = "/json", method = RequestMethod.GET)
  public @ResponseBody TestBean testAjax(
          HttpServletRequest req,
          @RequestParam(value = "type", required = false) String type,
          @RequestParam("track") String track) {
      return new TestBean();
  }
  </code></pre>
  
  <p>and then <code>/json?type=abc&amp;track=aa</code> or <code>/json?track=rr</code> will work</p>