From the course: Complete Guide to Spring MVC
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Exceptions overview - Spring Tutorial
From the course: Complete Guide to Spring MVC
Exceptions overview
- [Instructor] Exceptions overview. When looking at your controller and controller advice classes, these can have exception handler methods to handle exceptions from controller methods. What is an exception handler? The exception handler annotation allows you to define custom methods to handle exceptions thrown by your controller methods instead of letting exceptions propagate to the user. So you don't want to cause app crashes or expose stack traces Spring lets you gracefully intercept them and provide custom responses or actions. So let's jump into IntelliJ to see this at play. Again, we are in our greeting controller class and I've added in this snippet to save us a bit of time and I'll walk you through what we have here. Okay? All right, so we want to add an exception handler to our code to handle exceptions such as invalidate format errors from the example that we had before where we had a custom date format. All right? So what I've done here is I've added exception handler, and…
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)
Declaration overview4m 32s
-
(Locked)
Declaration: AOP proxies6m 23s
-
(Locked)
Mapping requests overview5m 19s
-
Mapping requests: URI patterns5m 50s
-
(Locked)
Mapping requests: Consumable media types4m
-
(Locked)
Mapping requests: Producible media types3m 53s
-
(Locked)
Handler methods overview3m 9s
-
(Locked)
Handler methods: Method arguments2m 54s
-
(Locked)
Handler methods: Return values5m 2s
-
(Locked)
Handler methods: Type conversion4m 47s
-
(Locked)
Model3m 16s
-
(Locked)
@InitBinder overview7m 46s
-
(Locked)
Validation3m 33s
-
(Locked)
Exceptions overview4m 39s
-
(Locked)
Exceptions: Method arguments3m 56s
-
(Locked)
Exceptions: Return values6m 47s
-
(Locked)
Controller advice10m 32s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-