所以我已经正确设置了一个侦听8080的jetty(基于eclipse)服务器。(我把一个小的hello world html进行测试)。 所以,如果我去
http://localhost:8080/index.html我的html显示。
现在我已经按照本教程使用Websockets。
https://gist.github.com/manzke/1021982web.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.htmlmy html is displayed.
Now I have followed this tutorial, to work with Websockets.
https://gist.github.com/manzke/1021982the 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/WebSocketBut 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>更多推荐
发布评论