希望在 Jetty 中使用多个静态目录。服务器运行时:
http://localhost:8282/A
http://localhost:8282/B
http://localhost:8282/C
- A 放在 X/V/A
- B放在Q/Z/B
- C放在P/T/C
以下失败:
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase(HTML_SITE);
ResourceHandler resource_handler1 = new ResourceHandler();
resource_handler1.setWelcomeFiles(new String[]{"index.html"});
resource_handler1.setResourceBase(HTML_CLIENTZONE_SITE);
// deploy engine
WebAppContext webapp = new WebAppContext();
String dir = System.getProperty("user.dir");
webapp.setResourceBase(getWebAppPath());
webapp.setContextPath("/");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler,resource_handler1 ,webapp, new DefaultHandler()});
server.setHandler(handlers);
如何添加多个静态资源目录?