在Tomcat 7.0.50下运行的一个正在运行的Spring MVC 4.0.2项目中,我正在尝试使用简单的代理和sockjs stomp端点实现Spring Websocket,遵循官方参考.因此,在contextConfigLocation(DistpacherServlet属性)中,我添加了一个值"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>
Run Code Online (Sandbox Code Playgroud)
在eclipse控制台(catalina log)中,当我启动Tomcat时,会出现行
- 初始化ExecutorService'clientInboundChannelExecutor'
- 初始化ExecutorService'weboutOutboundChannelExecutor'
- 初始化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 for Spring Websocket,不幸的是它不起作用