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.

Exceptions: Method arguments

Exceptions: Method arguments - Spring Tutorial

From the course: Complete Guide to Spring MVC

Exceptions: Method arguments

- Exceptions: method arguments. What are method arguments in exception handler annotation? When an exception is thrown in a Spring MVC application and @ExceptionHandler method can handle it, as we've seen before, and these methods can take various arguments to provide useful information about the exception, the request, or the user's context. The required argument would be exception. This is the most basic argument. It gives you the actual exception object, which contains details like error message, and stack trace. There are additional optional arguments that you could use that we've seen in our examples before. These give additional information about the context of the request or exception. So as we've seen with the HandlerMethod, this is details about the controller method that caused the exception. With ServletRequests, this is where you'll access the low-level servlet API for the request or response. With Locale, this is the user's locale, for language or region specific error…

Contents