@RequestParam 和 @PathVariable
URL的比较
功能比较
- 相同点
- 用于从request中接收请求的
- 都可以接收参数,
- 不同点
- @RequestParam 是从request里面拿取值
- @PathVariable 是从一个URI模板里面来填充
代码实现比较
@RequestParam
http://localhost:8080/springmvc/hello/1?user=10&address=1
public String getDetails(