SpringMvc中@PathVariable注解简单的用法

@PathVariable

/**
* @PathVariable 可以来映射 URL 中的占位符到目标方法的参数中.
* @param id
* @return
*/

 

jsp页面请求

<a href="springmvc/testPathVariable/1">Test PathVariable</a>

Action中方法

@RequestMapping("/testPathVariable/{id}")
public String testPathVariable(@PathVariable("id") Integer id) {
System.out.println("testPathVariable: " + id);
return SUCCESS;
}

posted @ 2018-02-10 09:21  逆水乘舟,不进则退  阅读(7441)  评论(0编辑  收藏  举报