Jetty에서 여러 개의 정적 디렉토리를 사용하려고합니다. 서버에서 실행되는 경우, A는 X/V에 위치jetty에 둘 이상의 리소스 디렉토리 추가
http://localhost:8282/A
http://localhost:8282/B
http://localhost:8282/C
- /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);
는 어떻게 추가 할 수 있습니다 하나 이상의 정적 자원 디렉토리를? 의 일부가 될 수있는,
Server server = new Server(8282);
WebAppContext context = new WebAppContext();
context.setContextPath("/");
ResourceCollection resources = new ResourceCollection(new String[] {
"project/webapp/folder",
"/root/static/folder/A",
"/root/static/folder/B",
});
context.setBaseResource(resources);
server.setHandler(context);
server.start();
이후 (예를 들어, WebAppContext를) ServletContext 내를 사용하여 파일을 열려면 :