The interceptors

Interceptors are popular in the Struts 2 framework, but Spring MVC can implement interceptors to manage sessions, logging, and auditing a user authentication process. The concept of an interceptor is similar to the filters in a typical Java Enterprise model but not exactly the same.

In order to create a handler interceptor, we must make use of org.springframework.web.servlet.HandlerInterceptor. The HandlerInterceptor defines three methods that can be used for pre-processing and post-processing requests:

  • PreHandle: This is called before a URL is executed, and returns a Boolean value. When it returns true, the handler execution chain continues, whereas when it returns false, the DispatcherServlet stops the execution of the entire ...

Get Spring MVC Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.