I really don't understand what the purpose of each one is since they perform very similar tasks.
Could someone explain to me what is the difference between an Interceptor and a Filter in Spring?
I really don't understand what the purpose of each one is since they perform very similar tasks.
Could someone explain to me what is the difference between an Interceptor and a Filter in Spring?
The following explanation can be extracted from Spring 's own documentation :
What this means is that filters are more suitable for handling requests and content related to views, while interceptors are more suitable for pre-processing tasks, such as authentication checks.
One advantage interceptors have over filters is that they are able to intercept between the controller and the view's render. On the other hand interceptors are
Beans
from Spring, so you have access to the whole context from them.