我正在尝试在Tomcat 8上设置"Echo“websocket示例,我相信我错过了告诉tomcat有关websocket类的步骤。
以下是我所做的:
当我启动这个应用程序时,我可以导航到echo.xhtml文件,但是不管我输入了什么url,我似乎都想不出如何到达网络套接字--我总是能得到404。在构造函数中放置断点,看起来好像没有加载websocket类。
通常,您可以在web.xml或其他框架配置中设置类配置,但我在示例web.xml中找不到Tomcat8 SVN (或任何其他Tomcat8)中的匹配配置。
对这是怎么做的有什么见解吗?
谢谢!
源代码
EchoAnotation.java,EchoEndpoint.java,ExamplesConfig.java Location:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/ http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo
Echo.xhtml location
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/
示例web.xml location
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/
My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>发布于 2013-12-22 17:05:57
弄明白了。最新版本的基于战争的网络应用程序自动进行组件扫描。我的不是,因为我包括了以下内容:
如果包含了tomcat,不包括!
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
</dependency>关于Websocket端点的参考:
https://tyrus.java.net/documentation/1.3.3/index/deployment.html
https://stackoverflow.com/questions/20723818
复制相似问题