Jetty Websockets无法连接到服务器(Jetty Websockets can't connect to server)

编程入门 行业动态 更新时间:2024-10-26 15:19:52
Jetty Websockets无法连接到服务器(Jetty Websockets can't connect to server)

所以我已经正确设置了一个侦听8080的jetty(基于eclipse)服务器。(我把一个小的hello world html进行测试)。 所以,如果我去

http://localhost:8080/index.html

我的html显示。

现在我已经按照本教程使用Websockets。

https://gist.github.com/manzke/1021982

web.xml配置如下:

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>tailor</display-name> <servlet> <servlet-name>WebSocket</servlet-name> <servlet-class>org.sample.websocket.ChatWebSocketServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>WebSocket</servlet-name> <url-pattern>/jetty-test/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>

要连接到我的Websocket,请使用以下URL:

ws://localhost:8080/jetty-test/servlet/WebSocket

但当我点击“连接”没有发生什么事情?,连接似乎没有建立..

我错过了什么吗? 或者是错误的网址?

谢谢 !

So I have correctly setup a jetty (eclipse based) server listening on 8080. (i put a little hello world html to test). So if I go to

http://localhost:8080/index.html

my html is displayed.

Now I have followed this tutorial, to work with Websockets.

https://gist.github.com/manzke/1021982

the web.xml is configured as follow:

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>tailor</display-name> <servlet> <servlet-name>WebSocket</servlet-name> <servlet-class>org.sample.websocket.ChatWebSocketServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>WebSocket</servlet-name> <url-pattern>/jetty-test/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>

To connect to my Websocket I use the following url:

ws://localhost:8080/jetty-test/servlet/WebSocket

But when I click on "Connect" nothing happend ?, The connect doesn't seems to establish..

Am I missing something? Or is the url that is wrong?

Thanks !

最满意答案

你的web.xml错了,替换

<url-pattern>/jetty-test/*</url-pattern>

通过

<url-pattern>/servlet/*</url-pattern>

Your web.xml is wrong, replace

<url-pattern>/jetty-test/*</url-pattern>

by

<url-pattern>/servlet/*</url-pattern>

更多推荐

本文发布于:2023-07-20 12:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1199630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   服务器   Websockets   Jetty   connect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!