通常情况下,我会将org.springframework.web.filter.DelegatingFilterProxy
这样的代码段添加到web.xml:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
但是使用Servlet 3.0 Container和Jetty,我删除了web.xml。我正试图通过以下方式将DelegatingFilterProxy添加到Jetty的发布中:
context.addFilter(DelegatingFilterProxy.class, "/*", EnumSet.allOf(DispatcherType.class));
但我收到错误:
No bean named 'org.springframework.web.filter.DelegatingFilterProxy-100555887' is defined
我应该如何创建和添加此过滤器?
答案 0 :(得分:13)
context.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")), "/*", EnumSet.allOf(DispatcherType.class));
似乎是正确的语法。