Filters vs Interceptors in Struts 2

后端 未结 6 1723
后悔当初
后悔当初 2021-01-31 04:29

What\'s the difference, really, between filters and interceptors? I realize that interceptors fire before and after an action, recursively, and filters can be configured to fir

6条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 05:08

    Struts 2 Framework is not dependent on Servlet API. Struts 2 Actions are not coupled to a container. Most often the servlet contexts are represented as simple Maps, allowing Actions to be tested in isolation.

    Filter is a part of Servlet API so Struts 2 Framework uses the concept of Interceptors to share the solution for some common concerns by different actions.

    Also you can easily write test cases for Interceptor and Action class.

提交回复
热议问题