【发布时间】:2014-01-15 03:08:44
【问题描述】:
我可以让 Grizzly 提供静态内容
我可以创建 servlet 过滤器来过滤命名的 servlet
但我无法让 servlet 过滤器过滤静态内容。我该怎么做?
这是我目前的代码:
WebappContext webappContext = new WebappContext("grizzly web context", "");
FilterRegistration authFilterReg = webappContext.addFilter("Authentication Filter", org.package.AuthenticationFilter.class);
// If I create a ServletContainer, I can add the filter to it like this:
// authFilterReg.addMappingForServletNames(EnumSet.allOf(DispatcherType.class), "servletName");
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(BASE_URI);
webappContext.deploy(httpServer);
// This works, but the content does not go through the authentication filter above
httpServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler(absolutePath), "/static");
【问题讨论】:
标签: java servlets servlet-filters grizzly