Java springSecurityFilterChain如何工作?
我尝试使用springSecurityFilterChain在spring框架中实现我自己的过滤器。我将在spring内容中实现该过滤器,而不是在web.xml中。在web.xml中,我只使用一个过滤器,它将所有请求委托给位于spring内容中的过滤器。例如: My web.xml文件:Java springSecurityFilterChain如何工作?,java,spring,spring-mvc,Java,Spring,Spring Mvc,我尝试使用springSecurityFilterChain在spring框架中实现我自己的过滤器。我将在spring内容中实现该过滤器,而不是在web.xml中。在web.xml中,我只使用一个过滤器,它将所有请求委托给位于spring内容中的过滤器。例如: My web.xml文件: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class&
<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>
现在,当某些人或其他应用程序希望从url获取资源时,我将使用我的筛选器调用doFilter方法:/example。因此,我们需要在secruity.xml文件中配置spring。在这一步,我要添加我不想授权使用html从。我将从POST请求中获取用户名和密码等参数
My security.xml:
<http use-expressions="true" auto-config="false" >
<!--
HERE I DECLARE MY CUSTOM FILTER BU WHERE IS PATTERN.
FROM WHERE SPRING WILL KNOWN THAT IF REQUEST COME /example
THAN CALL METHOD doFilter FROM CLASS myapplication.filters.ExampleFilter
-->
<custom-filter ref="ExampleFilter " />
</http>
<bean id="ExampleFilter " class="myapplication.filters.ExampleFilter"></bean>
为什么你的过滤器不同于处理j_spring_security_check的post请求的普通过滤器?这基本上就是你想要的。。。
<http use-expressions="true" auto-config="false" >
<!--
HERE I DECLARE MY CUSTOM FILTER BU WHERE IS PATTERN.
FROM WHERE SPRING WILL KNOWN THAT IF REQUEST COME /example
THAN CALL METHOD doFilter FROM CLASS myapplication.filters.ExampleFilter
-->
<custom-filter ref="ExampleFilter " />
</http>
<bean id="ExampleFilter " class="myapplication.filters.ExampleFilter"></bean>