Shortest code to start embedded Jetty server

前端 未结 5 1127
醉酒成梦
醉酒成梦 2021-01-30 15:30

I\'m writing some example code where an embedded Jetty server is started. The server must load exactly one servlet, send all requests to the servlet and listen on localhost:80

5条回答
  •  后悔当初
    2021-01-30 15:46

            Server server = new Server(8080);
            Context root = new Context(server, "/");
            root.setResourceBase("./pom.xml");
            root.setHandler(new ResourceHandler());
            server.start();
    

提交回复
热议问题