具有Spring Security且没有web.xml的Jetty addFilter [英] Jetty addFilter with Spring Security and no web.xml

查看:172
本文介绍了具有Spring Security且没有web.xml的Jetty addFilter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我会将带有以下代码段的org.springframework.web.filter.DelegatingFilterProxy添加到web.xml:

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> 

但是使用Servlet 3.0容器和码头,我删除了web.xml.我正在尝试通过以下方式将DelegatingFilterProxy添加到Jetty的启动中:

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));

但我收到错误消息:

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

我应该如何创建和添加此过滤器?

How am I supposed to create and add this filter?

推荐答案

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

似乎是正确的语法.

这篇关于具有Spring Security且没有web.xml的Jetty addFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆