使用 jetty 将 Web 应用程序嵌入到桌面应用程序中
我有一个在tomcat下运行的war文件,我需要将其作为桌面应用程序,大多数人建议嵌入jetty服务器作为桌面应用程序,任何人都可以通过示例解释如何做到这一点。我有点困惑如何做到这一点或一些将 jetty 服务器嵌入为桌面应用程序的教程。
I have an war file with runs under tomcat i need to make it as an desktop application and most of them recommend to embedded an jetty server as an desktop application can any one explain how to do it with an example. I am little confused how to do it or some tutorials that embedded jetty server as desktop application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以选择以下选项:
These are your options:
如果你敢尝试的话,嵌入 Jetty 真的很简单。乍一看,Web 服务器是神秘的野兽,但它们实际上只是打开服务器套接字并侦听 HTTP 请求的“简单”Java 应用程序。 只需创建一个
Server
和start() 实例
它。这将创建几个新线程,Jetty 将在其中处理请求。你的主线程可以自由地做它想做的任何事情。要停止它,请调用
stop()
和join()
。Embedding Jetty is really simple if you dare to try it. At first glance, web servers are mysterious beasts but they are really just "simple" Java applications which open a server socket and listen to HTTP requests. Just create an instance of
Server
andstart()
it.That will create a couple of new threads in which Jetty will handle requests. Your main thread is free to whatever else it wants to do. To stop it, call
stop()
andjoin()
.