简体   繁体   English

将Web界面添加到现有项目

[英]Add Web Interface to existing Project

I tried to understand this several times allready, but still have not found out how this should be done. 我已经准备好几次了解这一点,但是仍然没有发现应该如何做。 I want to create a web interface for some existing console or swing application. 我想为一些现有的控制台或swing应用程序创建Web界面。 Something like the web interface SABNzb offers (I know, it's Python – it's just an example). SABNzb提供的Web界面之类的东西(我知道,它是Python,这只是一个示例)。

I have looked at several technologies allready, like creating web services using a tomcat server, or java server pages/faces, but all the tutorials that I found so far start with "Create a new Web Project..." at wich point I stop because this is not what I want! 我已经研究了几种技术,例如使用tomcat服务器或Java服务器页面/界面创建Web服务,但是到目前为止,我发现的所有教程都以“创建新的Web项目...”开头,直到我停下来为止因为这不是我想要的! I have a finished an application in which I want to integrate a web interface, not some web service that instantiates my program as a local variable and uses its code. 我完成了一个要集成Web界面的应用程序,而不是将Web实例化为本地变量并使用其代码的Web服务。 So basicaly it feels like all the tutorials I find are the wrong way around. 因此,从根本上来说,我觉得我发现的所有教程都是错误的方法。

The core procedure of this is clear, the application should listen for http requests on a port I choose and answer with a created html code to it. 核心过程很清楚,应用程序应该在我选择的端口上侦听http请求,并使用创建的html代码对其进行回答。 So basicaly I could open a port using a socket and write an html page to its output on connect. 因此,基本上我可以使用套接字打开端口,并在连接时将html页面写入其输出。 But this rather feels like inventing the wheel all over again, also I'm not sure how an interactive web page would work this way. 但这就像重新发明轮子一样,我也不知道交互式网页将如何以这种方式工作。

Maybe I am thinking somewhat strange here or did not understand how some of these things work, but I am pretty unexperienced with web technologies, so grasping the concept is rather hard at the moment. 也许我在这里觉得有些奇怪,或者我不了解其中的某些功能,但是我对Web技术没有任何经验,因此目前很难理解这个概念。 Can anyone point me to a tutorial that shows how this might be done, or some other source of information on it? 谁能指出我的教程,说明如何做到这一点,或有关它的其他信息来源?

You don't need JSP or JSF; 您不需要JSP或JSF。 all you need is a servlet. 您只需要一个servlet。 It's an HTTP listener class. 这是一个HTTP侦听器类。 You can do REST with that. 您可以这样做。

The moment you say that you have to deploy your servlet in a WAR on a servlet/JSP engine. 当您说到必须在servlet / JSP引擎上的WAR中部署servlet时。 Tomcat is a good choice. Tomcat是一个不错的选择。

Google for a servlet tutorial and you'll be on your way. Google提供Servlet教程,您将一路顺风。

My First Tomcat Servlet 我的第一个Tomcat Servlet

Ok, thanks to duffymos answer and comments i realized i was actualy searching with the wrong keywords. 好的,感谢duffymos的回答和评论,我意识到我实际上是在搜索错误的关键字。 Embedded web server is the thing i was looking for. 嵌入式Web服务器是我一直在寻找的东西。

Like Simple or build in HTTPServer class in java. Simple一样,或者在Java中构建HTTPServer类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM