@PathVariable 映射 URL 绑定的占位符app
带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程当中具备里程碑的意义
经过 @PathVariable 能够将 URL 中占位符参数绑定到控制器处理方法的入参中:URL 中的 {xxx} 占位符能够经过@PathVariable(“xxx“) 绑定到操做方法的入参中。
主要是根据请求方法进行类的区别spa
例子:code
//@PathVariable能够用来映射URL中的占位符到目标方法的参数中 @RequestMapping("/testPathVariable/{id}") public String testPathVariable(@PathVariable("id") Integer id) { System.out.println("testPathVariable:"+id); return SUCCESS; }