用Java创建一个简单的HTTP服务器? [英] Create a simple HTTP server with Java?
问题描述
用Java创建一个简单的HTTP服务器最简单的方法是什么?有没有共享的图书馆来促进这一点?我只需要回应 GET / POST
,我不能使用应用程序服务器。
什么是使用 使用 rel =noreferrer> Jetty 。以下是嵌入码头的教程。 (这是过时的教程)。
Jetty非常轻便,但它确实提供了一个servlet容器,这可能与使用应用程序服务器的要求相矛盾。
您可以嵌入Jetty服务器到你的应用程序中Jetty允许使用嵌入式或servlet容器选项。
What's the easiest way to create a simple HTTP server with Java? Are there any libraries in commons to facilitate this? I only need to respond to GET/POST
, and I can't use an application server.
What's the easiest way to accomplish this?
Use Jetty. Here's a tutorial for embedding Jetty. (Here's an outdated tutorial.)
Jetty is pretty lightweight, but it does provide a servlet container, which may contradict your requirement against using an "application server".
You can embed the Jetty server into your application. Jetty allows EITHER embedded OR servlet container options.
这篇关于用Java创建一个简单的HTTP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!