Jetty addFilter with Spring Security and no web.xml

為{幸葍}努か 提交于 2019-12-03 12:06:21

问题


Normally I would have added org.springframework.web.filter.DelegatingFilterProxy with a snippet like this to 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> 

But with Servlet 3.0 Container and Jetty, I've removed web.xml. I'm trying to add DelegatingFilterProxy to Jetty's launch with:

context.addFilter(DelegatingFilterProxy.class, "/*", EnumSet.allOf(DispatcherType.class));

but I get error:

No bean named 'org.springframework.web.filter.DelegatingFilterProxy-100555887' is defined

How am I supposed to create and add this filter?


回答1:


context.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")), "/*", EnumSet.allOf(DispatcherType.class));

seems to be the correct syntax.



来源:https://stackoverflow.com/questions/19053848/jetty-addfilter-with-spring-security-and-no-web-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!