@PathVariable和@RequestParam的区别

来源:互联网 发布:sqlserver存储过程作用 编辑:程序博客网 时间:2024/05/17 07:33

请求路径上有个id的变量值,可以通过@PathVariable来获取  @RequestMapping(value = "/page/{id}", method = RequestMethod.GET) 
@RequestParam用来获得静态的URL请求入参     spring注解时action里用到。

1:通过变量传值:

@RequestParam(value = "fjbm", required = true) String fjbm

 

2:默认方法后面跟变量传值:

@PathVariable(value = "id") Long id

1 0
原创粉丝点击