From the course: Spring: Spring MVC
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Global exception handler for application
From the course: Spring: Spring MVC
Global exception handler for application
- In the previous video, we established the entire login flow and we also did an exception handling for that login flow. Now, when we did the exception handling, if you remember, we were in the LoginController, we tried to throw something from there and the exception handler was written in the LoginController itself. However, sometimes you may have a requirement to apply this exception handler to all exceptions that occur in any of your controllers. So what I'm trying to tell you here is that we may need to set up a global exception handler for the entire application. So no matter which controller throws exceptions, you need to make sure that the same kind of exception handling mechanism applies. So that's the demo that we're now going to do. Let's see the slide for the steps. You first add a class for the exception handler. So this is the global exception handler that we are adding now. So let's go back to the IDE…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
DispatcherServlet and special bean types3m 12s
-
(Locked)
Exception flow handler implementations4m 33s
-
(Locked)
Custom error page and Login controller4m 1s
-
(Locked)
Add method for selecting a user5m 51s
-
(Locked)
Add exception handler in Controller6m 28s
-
(Locked)
Global exception handler for application4m 52s
-
(Locked)
Default model attributes using @ControllerAdvice4m 27s
-
(Locked)
-
-
-
-
-