Handler mappings and Interceptors

In the version before Spring 2.5 (before there was support for Annotations), the mapping between a URL and a Controller (also called a handler) was expressed using something called a handler mapping. It is almost a historical fact today. The use of annotations eliminated the need for an explicit handler mapping.

HandlerInterceptors can be used to intercept requests to handlers (or controllers). Sometimes, you would want to do some processing before and after a request. You might want to log the content of the request and response, or you might want to find out how much time a specific request took.

There are two steps in creating a HandlerInterceptor:

  1. Define the HandlerInterceptor.
  2. Map the HandlerInterceptor ...

Get Mastering Spring 5.0 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.