Javascript JQuery可以';t连接到弹簧腹板座

Javascript JQuery可以';t连接到弹簧腹板座,javascript,spring,spring-websocket,Javascript,Spring,Spring Websocket,我正在尝试使用Spring和JS实现推送通知 我已将我的服务配置如下: @Controller public class GreetingController { @MessageMapping("/hello") @SendTo("/topic/greetings") public Greeting greeting(String namethrows Exception { return new Greeting("Hello, " + name "!"); }

我正在尝试使用Spring和JS实现推送通知

我已将我的服务配置如下:

@Controller
public class GreetingController {


  @MessageMapping("/hello")
  @SendTo("/topic/greetings")
  public Greeting greeting(String namethrows Exception {
    return new Greeting("Hello, " + name "!");
  }

}

在客户端上,我正在尝试连接到服务:

var ws = new WebSocket('ws://localhost:8810/gs-guide-websocket');
但在控制台中,我看到了这样的信息:

Firefox can't establish a connection to the server at ws://localhost:8810/gs-guide-websocket
如果我尝试点击URL,会得到一个问候语:
欢迎来到SockJS


为什么JS不能连接到套接字?

调用
registry.addEndpoint(“/gs-guide-websocket”).withSockJS()使用SockJS回退在WebSocket端点上注册STOMP。似乎大部分代码都来自于此,它在websocket上使用STOMP。您尝试过完整的示例吗?我们对第三方代码有限制。我有Spring,但没有stomp.js。如果您想直接使用WebSockets API,可以使用。互联网上可能也有这样的例子。只要确保它们不是用来跺脚的。
Firefox can't establish a connection to the server at ws://localhost:8810/gs-guide-websocket