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.

Customization and i18n

Customization and i18n

- [Instructor] Customization and internationalization. Customization and internationalization error responses in Spring MVC. In Spring MVC, error handling can be customized to provide clear, consistent, and localized error messages, improving the client experience. You can leverage tools like ResponseEntityExceptionHandler, ProblemDetail, and the MessageSource interface for internationalization. Let's look at customizing some error responses, starting with extending the ResponseEntityExceptionHandler. Spring's ResponseEntityExceptionHandler provides a base class for handling exceptions in a centralized manner. By extending this class, you can implement custom error handling logic. You can override specific methods, annotate with it ExceptionHandler to handle different exceptions in your application. Here in this example, the exception handler catches ResourceNotFoundException, and then builds a ProblemDetail instance. And then finally, what does it do? It returns it in the response…

Contents