Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Spring boot whitelabel error page

Customizing Whitelabel error in Thymeleaf

Spring Boot by default installs a ‘whitelabel’ Error page that you see in a browser client if you encounter a server error. You can customize it as needed based on your view technology, find the below post to override it in thymeleaf.

Step 1: Disable default error page in application.properties

#Disabling Default while lable error
server.error.whitelabel.enabled=false

Step 2: Adding a custom error page (error.html)

Overriding the error page with your own depends on the templating technology that you use. Here since I am using Thymeleaf, i have added error.html template.



    404 - resource not found

404 - Resource not found

The requested resource was not found; template - specific

Error Info

Status

Step 3: Configure pom.xml

Just add web, thymeleaf starter to your pom or gradle file.

4.0.0org.springframework.boot
		spring-boot-starter-parent
		2.2.8.RELEASEcom.candidjava
	customwhitelabel_error
	0.0.1-SNAPSHOTcustomwhitelabel_errorDemo project for Spring Boot1.8org.springframework.boot
			spring-boot-starter-web
		org.springframework.boot
			spring-boot-starter-thymeleaf
		org.springframework.boot
				spring-boot-maven-plugin
			

Step 4: Launch as Spring boot application (CustomwhitelabelErrorApplication.java)

package com.candidjava.customwhitelabel_error;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CustomwhitelabelErrorApplication {

 public static void main(String[] args) {
  SpringApplication.run(CustomwhitelabelErrorApplication.class, args);
 }

}


This post first appeared on Core Java,Servlet,Jsp,Struts,Hibernate,Spring Fram, please read the originial post: here

Share the post

Spring boot whitelabel error page

×

Subscribe to Core Java,servlet,jsp,struts,hibernate,spring Fram

Get updates delivered right to your inbox!

Thank you for your subscription

×