@PathVariable注解的用法 [ 技术杂谈 ]
九叶的小窝 文章 正文

九叶
{{nature("2020-12-27 16:31:43")}}更新@PathVariable注解的作用****
映射URL绑定的占位符
@PathVariable 注解可以将 URL 中占位符参数绑定到控制器处理方法的入参中;URL 中的 {xxx} 占位符可以通过@PathVariable(“xxx“) 绑定到操作方法的入参中。
Demo:
/**
* 用户注册 根据code获取sessionKey和OpenId并保存; 向客户端推送注册欢迎的webscoket消息
* @return user对象 (id) 注意不含sessionKey和OpenId等保密信息
*/
@GetMapping("/app{appId}/register")
public User weixinRegisterUser(@PathVariable (value="appId") int appId,@Param (value="code") String code){
User user = userService.registerUser(appId,code);
//异步 发送欢迎来到黑科Online
SystemMsg systemMsg=new SystemMsg(user.getId(),RegisterMsg, new Timestamp(System.currentTimeMillis()),10);
webSocketFeignService.sendWebSocketSystemMsg(systemMsg);
return user;
}
转自: https://blog.csdn.net/qq_37896194/article/details/84453975
{{nature('2021-12-07 15:29:00')}} {{format('2286')}}人已阅读
{{nature('2021-01-31 20:01:00')}} {{format('1069')}}人已阅读
{{nature('2020-12-11 21:17:00')}} {{format('989')}}人已阅读
{{nature('2021-04-22 15:16:00')}} {{format('983')}}人已阅读
目录
标签云
一言
评论 0
{{userInfo.data?.nickname}}
{{userInfo.data?.email}}