Colonies in New Delhi, India are categorized based on the easy access the daily needs. Here are some colonies from Delhi and their area and under which category these colonies fall.
Prime ministers of Jammu and Kashmir
List of Prime Ministers in Indian occupied Kashmir.
- Mehr Chand Mahajan - He was in office from 15 October 1947 to 5 March 1948
- Sheikh Abdullah(1905 - 1982) - He was in office from 5 March 1948 to 9 August 1953
- Bakshi Ghulam Mohammad - He was in office from 9 August 1953 to 29 February 1964
- Khwaja Shamsuddin - He was in office from 12 October 1963 to 29 February 1964
- Ghulam Mohammed Sadiq(1912 – 1971) - He was in office from 29 February 1964 to 30 March 1965
Custom error page in spring boot web application
Spring provide an out-of-the-box "Whitelabel Error Page". When any error occurs in our Spring application this default error page will appear.
Which look like as below:
How to disable the OOTB or whitelabel error page in Spring?
We can disable the default whitelabel error page, which is OOTB error page of Spring application by setting a property 'server.error.whitelabel.enabled' to false in application.properties property file.
server.error.whitelabel.enabled=false
How to create custom error page in Spring?
Spring provide a functional interface ErrorController to handle the errors. We need to create a controller class by implementing this interface ErrorController to handle the custom error and show different error message and pages to end users.
Since ErrorController is a functional interface, hence this interface contains only one method 'getErrorPath()'. In Spring 2.3.0 this method has been deprecated and since 2.3.0 we may use property 'server.error.path' to specify the error path.
This(server.error.path) property we can set in our application.properties file.
server.error.path=/error
Now create a CustomErrorHandlerController class which will implement ErrorController interface. In this class we will create a @RequestMapping for path /error and render the request to our custom error page. Below is the sample code, here we have created customErrorPage() method which is mapped with /error path.
CustomErrorHandlerController.java
import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class CustomErrorHandlerController implements ErrorController{ @Override public String getErrorPath() { return null; } @RequestMapping("/error") public String customErrorPage() { return "views/error"; } }
You may wondering why we have use the default method in this class which is returning null. This is because we have to provide the definition of all the method of an interface otherwise it will generate compile time error.
Now create a error.html page under views, which will appear when any error occur in the Spring application.
error.html
<html> <title>Spring custom error page</title> <body> <h1>Ooops!!</h1> <div> <h3>Something unexpected happened</h3> <p>If you are seeing this message frequently then, please report us. </p> <br /> </div> </body> </html>
We have done with changes now run the application and validate the error page functionality. Next time when system will generate any error then you will see this custom error page instead of whitelabel error page. You may also render to different error pages based on errors and their definition
e.g. error code 404 render to 404-error.html page and
error 400 render to 400-error.html page.
These all we can handle in customErrorPage method. We need to create an object of HttpServletRequest and check the status using if-else condition and return the respective error page.
Hope this helps you!