@PathVariable用来接收请求路径中的占位符值。
例子如下:
@Controller
@RequestMapping("/test")
public class TestController {
/**
* 请求路径:http://localhost:8080/test/show/1/james
*/
@RequestMapping("/show/{id}/{name}")
public void test5(@PathVariable("id") long id, @PathVariable("name") String name) {
System.out.println(id + " " + name);
}
}