Filters vs Interceptors in Struts 2

后端 未结 6 1725
后悔当初
后悔当初 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:16

    the interceptor stack fires on every request.
    filters only apply to the urls for which they are defined.

    edit -- you use one or the other depending on need. Lets say you need to verify a cookie is present for every request. User an interceptor. Lets say that you need to pop up an external app on some requests (driven by a url), use a filter.

    I think interceptors are the more commonly used tool...

    why would you have a url with no associated action?

提交回复
热议问题