Stomp over socket using sockjs can't connect with Spring 4 WebSocket

前端 未结 4 2068
南方客
南方客 2020-12-06 13:51

Trying to use Spring 4 WebSocket with STOMP over socket using sockjs. And i faced a problem.

My configuration:

websocket.xml - part of spring context

4条回答
  •  醉梦人生
    2020-12-06 14:20

    firstly, you have set destination prefix with app, so you must add 'app' into your request url. e.g. if i wanted to request for '/ws', i should create SockJS with path '/server/app/ws', also you can code with var socket = new SockJS("") and you know the 'server' is your project name over springmvc.

    secondly, you must add the path '/app/*' to org.springframework.web.servlet.DispatcherServlet so as to avoid the path with prefix '/app' intercepted by interceptor defined in web.xml.

提交回复
热议问题