这是我的代码-
Server server = new Server();
ServerConnector pxy = new ServerConnector(server);
pxy.setPort(8080);
server.addConnector(pxy);
HandlerCollection handlers = new HandlerCollection();
ServletContextHandler test1 = new ServletContextHandler(handlers, "/test1", ServletContextHandler.NO_SESSIONS);
ServletContextHandler test2 = new ServletContextHandler(handlers, "/test2", ServletContextHandler.NO_SESSIONS);
ServletHolder rootServletHolder = new ServletHolder(root.class);
test1.addServlet(rootServletHolder, "/test1/*");
ServletHolder testServletHolder = new ServletHolder(test.class);
test2.addServlet(testServletHolder, "/test2/*");
server.setHandler(handlers);
server.start();
server.join();
当我转到http://domainName.com:8080/test1或http://domainName.com:8080/test2时,我收到未找到错误消息。
码头启动看起来像这样-
2013-06-07 18:58:59.871:INFO:oejs.Server:main: jetty-9.0.3.v20130506 2013-06-07 18:58:59.895:INFO:oejsh.ContextHandler:main: 开始 oejsServletContextHandler@7c87c24a{ /test1,null,AVAILABLE} 2013-06-07 18:58:59.896:INFO:oejsh.ContextHandler:main: 启动 oejsServletContextHandler@34e4c825{/test2,null,AVAILABLE} 2013-06-07 18:58:59.919:INFO :oejs.ServerConnector:main: 启动 ServerConnector@3932f2b2{HTTP/1.1}{0.0.0.0:8080}