1
靜態網頁我可以這樣來配置靜態內容:基本HTTP驗證在碼頭8
ContextHandler staticContext = new ContextHandler();
staticContext.setContextPath("/");
staticContext.setResourceBase(".");
staticContext.setClassLoader(Thread.currentThread().getContextClassLoader());
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase(webDir);
staticContext.setHandler(resourceHandler);
現在我想設置基本HTTP認證爲我所有的靜態文件。我怎樣才能做到這一點?
PS。我使用的是嵌入式碼頭全無的web.xml