你不能具有可选的路径变量,但是可以有两个调用相同服务代码的控制器方法:
@RequestMapping(value = "/json/{type}", method = RequestMethod.GET)public @ResponseBody TestBean typedTestBean( HttpServletRequest req, @PathVariable String type, @RequestParam("track") String track) { return getTestBean(type);}@RequestMapping(value = "/json", method = RequestMethod.GET)public @ResponseBody TestBean testBean( HttpServletRequest req, @RequestParam("track") String track) { return getTestBean();}


