Difference between Interceptors and Filters - Is this right?

后端 未结 4 1427
长发绾君心
长发绾君心 2021-02-05 17:49

I\'m researching this so that I can respond better in interviews. I\'ve been searching around for a clear and concise answer.

So far, and by all means correct me if I a

4条回答
  •  逝去的感伤
    2021-02-05 18:02

    In one of the interview I answered this question like,

    Interceptors are struts2 concept and application developer has control over it. Also, It works withing struts2 application boundary and it has access to Actions, ValueStack and other objects along with Struts2 goodies.

    While Filter is more suitable for deployment time configurations. It has limited access to application, And in most cases its generic for most of the web-app deployed in server.

    If logic in code is more coupled with Application, its better suited for interceptor or else if its infrastructure, we can place it in servlet filter.

提交回复
热议问题