0
有人可以解釋爲什麼此代碼在startFileHTTP()停止?碼頭服務器啓動,但程序的其餘部分不起作用。我是否需要研究多線程編程?行爲解釋
try {
startFileHTTP();
} catch (Exception e) {
e.printStackTrace();
}
public void startFileHTTP() throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("/test");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
server.setHandler(handlers);
server.start();
server.join();
}
控制檯:
2011-02-10 13:55:47.828:INFO::jetty-7.1.6.v20100715
2011-02-10 13:55:47.953:INFO::Started [email protected]:8080