如何部署 Tomcat 的示例 websocket 应用程序? [英] How to deploy Tomcat's example websocket applications?

查看:37
本文介绍了如何部署 Tomcat 的示例 websocket 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解如何部署 Apache Tomcat 7 中引用的示例 WebSocket How-To 页面.

I am trying understand how to deploy the examples referenced in the Apache Tomcat 7 WebSocket How-To page.

应用程序开发部分建议阅读 WebSocketServlet 类.但是查看示例的 服务器端代码,三个例子中的类都没有extend WebSocketServlet,这正是我所期望的.

The Application Development section advises reading javadoc on WebSocketServlet class. But looking at the server side code of the examples, none of the classes in the three examples extend WebSocketServlet, which is what I had expected it to do.

十多年后我又回到了 servlet 开发,对这些示例中的所有注释感到很迷茫.是否有另一个 How-To 包含使用 servlet 启动和运行 WebSocket 的分步简单说明?

I am returning to servlet development after over a decade and feeling quite lost with all the annotations in these examples. Is there another How-To that has step-by-step simple instructions for getting a WebSocket using servlet up and running?

推荐答案

下载分发时Apache Tomcat(7.0.37 是目前的最新版本),您将已经部署了 examples Web 应用程序.它带有 WebSocket 示例.您不必自己部署它.

When you download the distribution of Apache Tomcat (7.0.37 is the latest version at the moment), you will have the examples web application already deployed. It comes with the WebSocket Examples. You don't have to deploy it yourself.

启动Tomcat并打开http://localhost:8080/examples.

Start Tomcat and open http://localhost:8080/examples.

点击WebSocket 示例并选择您想要的任何 WebSocket 示例.

Click WebSocket Examples and pick whatever WebSocket example you want.

除了使用 bin/catalina.sh run(或任何适合您的命令)启动 Tomcat 之外,您无需执行任何其他操作.

You don't have to do anything other than to start Tomcat with bin/catalina.sh run (or whatever command works for you).

当您查看 [TOMCAT_HOME]/webapps/examples 目录时,您可能需要查看 WEB-INF/web.xml,您可以在其中看到部署的 WebSocket servlet.

When you look into [TOMCAT_HOME]/webapps/examples directory, you may want to look at WEB-INF/web.xml where you see the WebSocket servlets deployed.

他们的源代码在[TOMCAT_HOME]/WEB-INF/classes/websocket目录下.

Their source code is in [TOMCAT_HOME]/WEB-INF/classes/websocket directory.

servlet websocket.echo.EchoMessage 确实扩展了 org.apache.catalina.websocket.WebSocketServlet.

The servlet websocket.echo.EchoMessage does extend org.apache.catalina.websocket.WebSocketServlet.

我想知道我是否应该询问您使用的 Apache Tomcat 版本?也许您使用其他一些不太新的版本?我建议从最新版本开始,因为它对我来说效果很好.

I wonder if I should have asked you about the version of Apache Tomcat you use? Perhaps you use some other not-so-recent version? I recommend to start with the latest version as it worked fine for me.

这篇关于如何部署 Tomcat 的示例 websocket 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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