Showing posts with label Custom Error Page. Show all posts
Showing posts with label Custom Error Page. Show all posts

Tuesday, 31 March 2020

Spring Boot - Displaying custom Error Page | Customize Whitelabel Error Page

🚀 Love Java & Spring Boot?

Don't miss out on more professional coding tutorials from Ram N Java!

SUBSCRIBE TO OUR CHANNEL

Why Customize Your Error Pages?

By default, Spring Boot provides a standard "Whitelabel Error Page." While functional, it doesn't look professional to your users. In this tutorial, we show you how to replace it with a stunning, custom-designed error page that matches your application's branding.

Steps to Create Your Custom Error Page

1. Prepare Your HTML File

Create an HTML file named error.html. This is the file Spring Boot will automatically look for when something goes wrong.

2. Place it in the Right Directory

For Spring Boot to detect your custom page automatically, place the error.html file inside the src/main/resources/templates/ directory if you are using a template engine like Thymeleaf.

3. Handling Specific Errors

You can even create specific pages for specific HTTP status codes! For example:

  • 404.html for "Page Not Found"
  • 500.html for "Internal Server Error"
Just place these in a folder named error inside your templates directory.

Summary

Transforming your Whitelabel error page is a simple step that makes your Spring Boot application look much more polished and professional. Watch the video above for a step-by-step code walkthrough!

Tutorials