J2EE Design Pattern

Intercepting filter

Interceptors intercept requests and process them. They help to avoid repetitive handler code such as logging and authorization checks.

In Spring –

A Spring interceptor is a class that either extends the HandlerInterceptorAdapter class or implements the HandlerInterceptor interface.

The HandlerInterceptor contains three main methods:

  • prehandle() – called before the execution of the actual handler
  • postHandle() – called after the handler is executed
  • afterCompletion() – called after the complete request is finished and the view is generated

These three methods provide flexibility to do all kinds of pre- and post-processing.

Published by

Unknown's avatar

sevanand yadav

software engineer working as web developer having specialization in spring MVC with mysql,hibernate

Leave a comment