在 Tomcat 7.0.50 下运行的 Spring MVC 4.0.2 项目中,我正在尝试使用简单的代理和 sockjs stomp 端点来实现 Spring Websocket,遵循官方参考。因此,在 contextConfigLocation(DistpacerServlet 属性)中,我添加了一个值“websocket-config.xml”,其中包含:
> <websocket:message-broker application-destination-prefix="/app" >
> <websocket:stomp-endpoint path="/monitor">
> <websocket:sockjs />
> </websocket:stomp-endpoint>
> <websocket:simple-broker prefix="/topic"/>
> </websocket:message-broker>
当我启动 Tomcat 时,在 Eclipse 控制台(catalina 日志)中,出现行
- 初始化 ExecutorService 'clientInboundChannelExecutor'
- 初始化 ExecutorService 'clientOutboundChannelExecutor'
- 初始化 ExecutorService 'messageBrokerSockJsScheduler'
- 将 URL 路径 [/monitor/**] 映射到 [class org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler] 类型的处理程序
在jsp页面中我把代码
. . . .
var socket = new SockJS("monitor");
var stompClient = Stomp.over(socket); . . . .
不幸的是,当我从 Chrome (v32) 加载 jsp 页面时,我收到此错误:
加载资源失败:服务器响应状态为 404(未找到)
http://localhost:8080/(ProjectName)/monitor/info
显然,我在本地进行此测试,然后所有其他 webapp 资源都可以在 http://localhost/(ProjectName) 正确访问。
怎么了?
**** 2014 年 2 月 20 日更新我试图关注这个已解决的堆栈问题,它建议将 Tomcat8 用于 Spring Websocket,不幸的是它不起作用