@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