Spring Websocket 和 404 连接状态 [英] Spring Websocket and 404 status on connection

查看:20
本文介绍了Spring Websocket 和 404 连接状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个在 Tomcat 7.0.50 下运行的 Spring MVC 4.0.2 项目中,我试图按照 官方参考.因此,在 contextConfigLocation(DistpacherServlet 属性)中,我添加了一个值websocket-config.xml",其中包含:

In a working Spring MVC 4.0.2 project running under Tomcat 7.0.50, I'm trying to implement Spring Websocket with simple broker and sockjs stomp endpoint, following the official reference. So, in the contextConfigLocation (DistpacherServlet property) I've add a value "websocket-config.xml" which contains:

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

在 Eclipse 控制台(catalina 日志)中,当我启动 Tomcat 时,出现行

In eclipse console (catalina log) when I start Tomcat, appear the rows

  • 初始化 ExecutorService 'clientInboundChannelExecutor'
  • 初始化 ExecutorService 'clientOutboundChannelExecutor'
  • 初始化 ExecutorService 'messageBrokerSockJsScheduler'
  • 将 URL 路径 [/monitor/**] 映射到类型为 [class org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler] 的处理程序上

在jsp页面我放了代码

In the jsp page I put the code

....
var socket = new SockJS("monitor");
var stompClient = Stomp.over(socket);....

. . . .
var socket = new SockJS("monitor");
var stompClient = Stomp.over(socket); . . . .

不幸的是,当我从 Chrome (v32) 加载 jsp 页面时,出现此错误:

Unfortunately when I load the jsp page from Chrome (v32), I get this error:

加载资源失败:服务器响应状态为 404(未找到)

Failed to load resource: the server responded with a status of 404 (Not Found)

http://localhost:8080/(ProjectName)/monitor/info

http ://localhost:8080/(ProjectName)/monitor/info

显然我是在本地进行这个测试,然后所有其他 webapp 资源都可以在 http://localhost/(ProjectName) 正确访问.

Obviously I'm doing this test locally, then all other webapp resources are reachable at http ://localhost/(ProjectName) correctly.

怎么了?

**** 2014 年 2 月 20 日更新我试图遵循 this 已解决的堆栈问题,这表明Spring Websocket 使用Tomcat8,可惜不行

**** Update 20 Feb 2014 I've tried to follow this resolved stack question, which suggests to use Tomcat8 for Spring Websocket, unfortunately it doesn't work

推荐答案

由于请求/monitor/info 而在服务器端有任何日志输出吗?DispatcherServlet 本身是如何映射的?我希望从你上面的内容中/".

Any log output on the server side as a result of the request to /monitor/info? How is the DispatcherServlet itself mapped? I would expect to "/" from what you have above.

SockJS 端点基本上是在 Spring MVC 中映射的 URL(带有 SimpleUrlHandlerMapping),因此请尝试其他 Spring MVC 映射控制器方法.并打开日志记录,是否有过滤器或其他返回 404 的东西?

The SockJS endpoint is basically a URL mapped in Spring MVC (with a SimpleUrlHandlerMapping) so try other Spring MVC mapped controller methods. And turn up logging, could there be a filter or something else returning the 404?

这篇关于Spring Websocket 和 404 连接状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆