有几个websocket编程过程中的问题

新手入门,很多不知的@ServerEndpoint(value = "/websocket/{equipmentId}")和@GetMapping("gaming/{gameId}")很想知道,这两句代码分别代表什么意思

@ServerEndpoint 是 javax.websocket.server包下的一个注解,看源码:

 @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ServerEndpoint {

    /**
     * URI or URI-template that the annotated class should be mapped to.
     * @return The URI or URI-template that the annotated class should be mapped
     *         to.
     */
    String value();

    String[] subprotocols() default {};

    Class<? extends Decoder>[] decoders() default {};

    Class<? extends Encoder>[] encoders() default {};

    public Class<? extends ServerEndpointConfig.Configurator> configurator()
            default ServerEndpointConfig.Configurator.class;
}

其中value代表的是你的webSocket服务端点的连接地址,可以像这样:
@ServerEndpoint(value = "/myWebSocket/{userId}")

而 @GetMapping是spring框架映射方法的一个注解:
Spring官方文档说:
@GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写。该注解将HTTP Get 映射到 特定的处理方法上。

@GetMapping("gaming/{gameId}")是springboot提供的注解,表示这个请求只可以用get方式请求,get方式就是你可以在浏览器中直接输入链接就可以打开。
对应的还有@PostMapping @DeleteMapping @PutMapping
在老版本的spring里面只有@RequestMapping(value='',method=..)

@ServerEndpoint(value = "/myWebSocket/{userId}")是javax.websocket提供的注解。也是定义一个路由

其实这几个注解都是定义路由的功能,当你想访问这些路由下面的方法的时候,只要访问value里面的值就可以了。

通过 重写@OnOpen方法,在OnOpen方法参数中,标明@PathParam("userId") Long userId即可获取对应value

在方法参数里面获取啊 比如:
@GetMapping("gaming/{gameId}")
@ResponseBody
public String getGameName(PathVariable("gameId") String gameId){
}
链接如下这样拼写
http://127.0.0.1:8080/ssm/student/delete/'+row.sid;
这是我以前写过的例子
图片说明

图片说明

图片说明