undertow

空正豪
2023-12-01

mark

public class HelloWorldServer {

public static void main(final String[] args) {

Undertow server = Undertow.builder()

.addHttpListener(8080, "localhost")

.setHandler(new HttpHandler() {

@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");

exchange.getResponseSender().

send("Hello World");

}

}).build();

server.start();

}

}

 类似资料: