MVC Interceptor is a MVC only concept. They are more or less like Servlet Filters. They can intercept requests to the controller only. AOP can be used to intercept calls to any public method in any Spring loaded bean.
So, the question is when you would use one over the other?
AOP is only option to use if you are trying to weave code into your service layer.
A Controller method can be intercepted by either an Aspect or a HandlerInterceptor. The differrence is that the AOP advice only has access to the controller being called, and the parameters being passed to the method. A HandlerInterceptor always has access to the complete HttpRequest, HttpResponse and the object being called. So, if your interceptor is doing something that requires it to always have access to the Request and response, you should use HandlerInterceptor. If you want to do something with the parameters to the controller method, you should write an Aspect
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad: