weixin_40246689
callowLu
2018-12-25 00:49

springboot websocket @MessageMapping注解不生效

  • spring
@Controller
public class WsController {

    @MessageMapping("ws/chat")
    public void handleChat(@Header("destination") String destination) throws Exception
    {
        System.out.println(destination);
    }

}

java springboot 使用websocket实现在线聊天,添加@MessageMapping("ws/chat")注解之后handleChat方法显示Method 'handleChat(java.lang.String)' is never used从未被调用,
websocket连接正常,消息发送也正常:

打开浏览器f12可见
<<< CONNECTED
version:1.1
heart-beat:0,0
>>> SEND
destination:http://localhost:8082/ws.chat
content-length:12

哈哈哈哈
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答