Difference Between Interceptor and Filter

Question 4, what is the difference between Spring's interceptor and Struts' Filter?

① The interceptor is based on the Java reflection mechanism , while the filter is based on the function callback .

② The filter depends on the servlet container, while the interceptor does not depend on the servlet container.

③Interceptors can only work on action requests , while filters can work on almost all requests .

④Interceptors can access objects in the action context and value stack, while filters cannot.

⑤ In the life cycle of 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 http://43.154.161.224:23101/article/api/json?id=325728235&siteId=291194637