Directory path and URL
I'm having difficulty figuring out how the directory path works for this jetty HTTP server. I've tried http://localhost:8080/test in a browser which doesn't list the directory files as expected (a C:\test directory exists). Am i at least using the correct path for the directory i'm trying to use? Is the browser URL i'm attempting correct?
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
ResourceHandler resourceHandle = new ResourceHandler();
resourceHandle.setDirectoriesListed(true);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("/test");
Syst开发者_运维问答em.out.println("resourcebase: " + resource_handler.getResourceBase()); //not working
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
server.setHandler(handlers);
server.start();
server.join();
Edit: print is not even working and no exceptions caught
try {
startFileHTTP();
} catch (Exception e) {
System.out.println("HTTP error");
e.printStackTrace();
}
I think that your problem is at
resource_handler.setResourceBase("/test");
Are you sure that the base path is C:\
?
精彩评论