@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
哈哈哈哈