From the course: Complete Guide to Spring MVC

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Controller advice

Controller advice

- [Instructor] Controller advice. Controller advice annotation is a feature in Spring MVC that centralizes exception handling, model attribute initialization and data binding configuration across your application. Let's break down its use cases and implement it in our own Hello World application. In Spring MVC, the controller advice annotation provides a global mechanism to three things, to handle exception, to initialize model attributes, and to customize data binding and makes your application more organized and easier to maintain. You'll see in our upcoming example that all shared logic lives in one place. The three main features of controller advice annotation is that global exception handling, the shared model attributes and the custom data binding. And we also have some advanced features within controller advice annotation where you can filter controllers. This is where you can limit the scope of controller advice to specific controllers, using annotations, base packages and…

Contents