@PathVariable get和post皆可,用来获取路径中的参数,必须带上@PathVariable @RequestMapping("/test/{id}") public String test(@PathVariable Integer id) { return Integer.toString(id); } 如果参数名字不一样,加上参数@PathVariable(value = “idd”) @RequestMapping("/test/{idd}"