Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ public MyErrorController() {}

@RequestMapping(value = "/error")
public String handleError(HttpServletRequest request) {

Integer statusCode =
Integer.valueOf(request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE).toString());

if(statusCode == HttpStatus.NOT_FOUND.value()) {
return "error-404";
}
else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
return "error-500";
}
else {
return "error";

Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);

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";
}
}
return "error";
}

@Override
Expand Down
13 changes: 10 additions & 3 deletions spring-boot/src/main/resources/templates/error-404.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<h1>Sorry we couldn't find the resource you are looking for</h1>
<a href="/">Go Home</a>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, we couldn't find the page you were looking for. </h1>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>
</html>
15 changes: 12 additions & 3 deletions spring-boot/src/main/resources/templates/error-500.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<h1>Oops! We spilled something but we're fixing it</h1>
<a href="/">Go Home</a>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, something went wrong! </h1>

<h2 class="text-center">We're fixing it.</h2>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>
</html>
13 changes: 11 additions & 2 deletions spring-boot/src/main/resources/templates/error.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<h1>Something went wrong! Our Engineers are on it temp</h1>
<a href="/">Go Home</a>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Something went wrong! </h1>

<h2 class="text-center">Our Engineers are on it.</h2>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>
6 changes: 0 additions & 6 deletions spring-boot/src/main/resources/templates/index.ftl

This file was deleted.