区别主要有一下几点:
1、Filter是Servlet规范的一部分,Interceptor是Spring等框架提供的,所以Filter只能用于Web应用,Interceptor可以用于非Web应用。
2、Interceptor归Spring管理,可以使用IOC中管理的对象,Filter则不能。
3、Filter只能在Servlet前后过滤,Interceptor的粒度是方法。
在Spring应用中,我们优先使用
区别主要有一下几点:
1、Filter是Servlet规范的一部分,Interceptor是Spring等框架提供的,所以Filter只能用于Web应用,Interceptor可以用于非Web应用。
2、Interceptor归Spring管理,可以使用IOC中管理的对象,Filter则不能。
3、Filter只能在Servlet前后过滤,Interceptor的粒度是方法。
在Spring应用中,我们优先使用