我编写了一个AEM过滤器,但没有被调用。 我们是否必须提供一些配置,除了班级以外? 下面是结构,那里有什么不对吗?
@SlingFilter(label = "ABC", description = "abc", metatype = false, generateComponent = false,
generateService = true, // True; required for Sling Filters
order = -8642, //lowest order as per my application
scope = SlingFilterScope.REQUEST)
@Properties({ @Property(label = "Vendor", name = "service.vendor", value = "abc", propertyPrivate = true) })
public class CoursePageFilter implements Filter {
protected Logger log = LoggerFactory.getLogger(getClass());
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
final SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;
final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
final Resource resource = slingRequest.getResource();
String curPageName = resource.getPath();
if (resource.getPath().startsWith("/xyz")) {
RequestDispatcher dispatch = slingRequest.getRequestDispatcher("/abc.html");
dispatch.forward(slingRequest, slingResponse);
return;
}
// to proceed with the rest of the Filter chain
chain.doFilter(request, response);
}
}