What is Spring MVC Interceptor and how to use it?

Technology CommunityCategory: SpringWhat is Spring MVC Interceptor and how to use it?
VietMX Staff asked 3 years ago

Spring MVC Interceptors are like Servlet Filters and allow us to intercept client request and process it. We can intercept client request at three places – preHandlepostHandle and afterCompletion.

We can create spring interceptor by implementing HandlerInterceptor interface or by extending abstract class HandlerInterceptorAdapter. We need to configure interceptors in the spring bean configuration file. We can define an interceptor to intercept all the client requests or we can configure it for specific URI mapping too.