20. Filter interceptor

The filter needs to be implemented in the servlet container. The interceptor can be applied to various environments such as javaEE and javaSE. The
interceptor can call various dependencies in the IOC container. The filter cannot be used before and after the request. The interceptor Can be detailed to each method

2. The difference between interceptor and filter:

  1. The interceptor is based on the reflection mechanism of java, and the filter is based on the function callback.
  2. The interceptor does not depend on the servlet container, and the filter depends on the servlet container.
  3. Interceptors can only work on action requests, while filters can work on almost all requests.
  4. The interceptor can access the objects in the action context and value stack, but the filter cannot.
  5. In the life cycle of the action, the interceptor can be called multiple times, while the filter can only be called once when the container is initialized

Guess you like

Origin blog.csdn.net/zyf_fly66/article/details/113944277
Recommended