SPRING CONCEPTS

MVC handler interceptor

Spring Concepts / MVC handler interceptor

An interceptor participates in MVC handler processing.

Understand the idea

Register the interceptor through MVC configuration. PreHandle can allow or stop handling; postHandle follows successful handler execution before HTML view rendering; afterCompletion runs after completion for the handled flow. Servlet filters wrap the Servlet chain at another layer. Async and exception paths affect callback execution.

A concrete example

filter before → preHandle → controller
→ postHandle → view → afterCompletion → filter after

In the application

See the independently runnable examples in Stage 30.

A component annotation alone does not register an interceptor for MVC routes.

See it in a working stage

Related concepts

Read the official documentation ↗
Java 21 · Spring Boot 4.1.1 · Edupoly