Skip to content
This repository has been archived by the owner on Sep 1, 2018. It is now read-only.

过滤器和拦截器的区别 #44

Open
hsipeng opened this issue Aug 8, 2017 · 0 comments
Open

过滤器和拦截器的区别 #44

hsipeng opened this issue Aug 8, 2017 · 0 comments

Comments

@hsipeng
Copy link
Owner

hsipeng commented Aug 8, 2017

过滤器和拦截器的区别:
  ①拦截器是基于Java的反射机制的,而过滤器是基于函数回调。
  ②拦截器不依赖与servlet容器,过滤器依赖与servlet容器。
  ③拦截器只能对action请求起作用,而过滤器则可以对几乎所有的请求起作用。
  ④拦截器可以访问action上下文、值栈里的对象,而过滤器不能访问。
  ⑤在action的生命周期中,拦截器可以多次被调用,而过滤器只能在容器初始化时被调用一次。
  ⑥拦截器可以获取IOC容器中的各个bean,而过滤器就不行,这点很重要,在拦截器里注入一个service,可以调用业务逻辑。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant