From the course: Spring: Spring MVC

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Add interceptor class

Add interceptor class

From the course: Spring: Spring MVC

Start my 1-month free trial

Add interceptor class

- [Lecturer] So let's get started with the steps. The first one, is to create a LoggingInterceptor class in our HPlus application. And we will do some logging of request data inside it. So let's go back to the IDE and I'm going to make another package here for interceptors. And inside this, let's create a class which is LoggingInterceptor. And this one, is as we discussed in the previous video, going to extend the HandlerInterceptorAdapter. That's the one. So this one, has got those three methods that we talked about, preHandle, postHandle and afterCompletion. So you can override one of those in order to facilitate any kind of pre or post processing logic that you may have. So let's override the preHandle. We do not want the super class call that's been done so, we'll eliminate that and let me just list out the steps. First, we will get all cookies then, we will get the session id from with the cookie and we log the…

Contents