Springboot - @PathVariable

@PathVariable 注解用于从request中接受参数

@PathVariable绑定URI模板变量值

@PathVariable是用来获得请求url中的动态参数的

@PathVariable用于将请求URL中的模板变量映射到功能处理方法的参数上。

@GetMapping("findUserByUserId/{id}")
public User findUserByUserId(@PathVariable("id") Integer id) {
    return userService.findUserByUserId(id);
}

以上url模板是findUserByUserId/{id},id作为参数。

猜你喜欢

转载自blog.csdn.net/A_bad_horse/article/details/113058698