views:

70

answers:

2

I have a filterclass that i normally will put in web.xml. may i know how to specify it inside spring applicationcontext so that i able to use spring features in my fitlerclass?

+3  A: 

Use a DelegatingFilterProxy.

leonm
Best. Class. Ever.
Gandalf
+2  A: 

leonm's answer is 100% correct, but like many things in Spring there are multiple ways of doing this (well at least in Spring Security's case).

You can also subclass SpringSecurityFilter and then add it to the Spring Security Filter Chain like this:

<bean id="mySecurityFilter" class="org.example.MySecurityFilter">
   ...setup like a normal bean
   <custom-filter position="LAST"/>
</bean>

Check out this link <security:custom-filter> for all the different values you can use for the position argument.

Gandalf
if my filterclass is nothing to do with spring security. i add up this way as well? let say i want to add custom ntlmhttpfilter class that i normally add in web.xml
cometta
Probably not, but since I did not know what your filter was doing I figured I would show you the second option.
Gandalf