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;
}

原文地址:https://www.cnblogs.com/zhangzhiqin/p/8438071.html