diff --git a/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java b/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java index d0c548e7bb..caa335ed23 100644 --- a/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java +++ b/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java @@ -15,19 +15,21 @@ public class MyErrorController implements ErrorController { @RequestMapping(value = "/error") public String handleError(HttpServletRequest request) { + + Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - Integer statusCode = - Integer.valueOf(request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE).toString()); + if (status != null) { + + Integer statusCode = Integer.valueOf(status.toString()); - if(statusCode == HttpStatus.NOT_FOUND.value()) { - return "error-404"; - } - else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) { - return "error-500"; - } - else { - return "error"; + if(statusCode == HttpStatus.NOT_FOUND.value()) { + return "error-404"; + } + else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) { + return "error-500"; + } } + return "error"; } @Override diff --git a/spring-boot/src/main/resources/templates/error-404.html b/spring-boot/src/main/resources/templates/error-404.html index 3d3adaefa6..cf68032596 100644 --- a/spring-boot/src/main/resources/templates/error-404.html +++ b/spring-boot/src/main/resources/templates/error-404.html @@ -1,7 +1,14 @@ + + + + -

Sorry we couldn't find the resource you are looking for

-Go Home +
+
+

Sorry, we couldn't find the page you were looking for.

+

Go Home

+
- + \ No newline at end of file diff --git a/spring-boot/src/main/resources/templates/error-500.html b/spring-boot/src/main/resources/templates/error-500.html index 979dd76764..5ddf458229 100644 --- a/spring-boot/src/main/resources/templates/error-500.html +++ b/spring-boot/src/main/resources/templates/error-500.html @@ -1,7 +1,16 @@ + + + + -

Oops! We spilled something but we're fixing it

-Go Home +
+
+

Sorry, something went wrong!

+ +

We're fixing it.

+

Go Home

+
- + \ No newline at end of file diff --git a/spring-boot/src/main/resources/templates/error.html b/spring-boot/src/main/resources/templates/error.html index 26d1a22b6c..bc517913b2 100644 --- a/spring-boot/src/main/resources/templates/error.html +++ b/spring-boot/src/main/resources/templates/error.html @@ -1,7 +1,16 @@ + + + + -

Something went wrong! Our Engineers are on it temp

-Go Home +
+
+

Something went wrong!

+ +

Our Engineers are on it.

+

Go Home

+
diff --git a/spring-boot/src/main/resources/templates/index.ftl b/spring-boot/src/main/resources/templates/index.ftl deleted file mode 100644 index ce0505006e..0000000000 --- a/spring-boot/src/main/resources/templates/index.ftl +++ /dev/null @@ -1,6 +0,0 @@ - - - -

Welcome Home

- -