Coding⏱️ 3 min read📅 2026-06-03

How to Fix: Spring Boot Remove Whitelabel Error Page

Remove white label error page in Spring Boot by using @ExceptionHandler and @ControllerAdvice.

Quick Answer: Use @ExceptionHandler to handle exceptions and remove the controller mapping for '/error'.

The white label error page is a common issue in Spring Boot applications, especially when trying to remove it. This error occurs when the application cannot find a controller mapping for the requested URL.

This issue affects developers who are using Spring Boot and have not properly configured their controllers or mappings.

💡 Why You Are Getting This Error

  • The primary cause of this error is that the @RestController annotation is missing on the IndexController class. This annotation is required to indicate that the class contains RESTful controllers.
  • Another possible cause is that the controller mapping for the '/error' URL is not correctly defined or is missing altogether.

✅ Best Solutions to Fix It

Enable Annotation-Based Mapping

  1. Step 1: Add the @RestController annotation to the IndexController class:
  2. Step 2:
    @RestController
  3. Step 3: Update the controller mapping for the '/error' URL to use the @ExceptionHandler annotation or a custom error handling mechanism.
  4. Step 4:
    @ExceptionHandler(HttpException.class)

Enable BeanCreationException Handling

  1. Step 1: Check if there are any other controllers or mappings that might be interfering with the '/error' URL.
  2. Step 2: Verify that all necessary dependencies and configurations are included in the application.

🎯 Final Words

To resolve this issue, enable annotation-based mapping by adding the @RestController annotation to the IndexController class. Additionally, update the controller mapping for the '/error' URL using the @ExceptionHandler annotation or a custom error handling mechanism. If the issue persists, check for other controllers or mappings that might be interfering with the '/error' URL and ensure all necessary dependencies and configurations are included in the application.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions