1
我能得到灰熊提供静态内容灰熊+静态内容+ Servlet过滤器
我可以创建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");
请你在我的灰熊的问题我们来看一看:http://stackoverflow.com/questions/35123194/jersey-2-render-swagger-static-内容正确,没有尾随斜线 – DerekY