Skip to content

Commit 48a7066

Browse files
committed
style pages
1 parent 0c6c5b9 commit 48a7066

5 files changed

Lines changed: 47 additions & 26 deletions

File tree

‎spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@ public MyErrorController() {}
1515

1616
@RequestMapping(value = "/error")
1717
public String handleError(HttpServletRequest request) {
18-
19-
Integer statusCode =
20-
Integer.valueOf(request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE).toString());
21-
22-
if(statusCode == HttpStatus.NOT_FOUND.value()) {
23-
return "error-404";
24-
}
25-
else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
26-
return "error-500";
27-
}
28-
else {
29-
return "error";
18+
19+
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
20+
21+
if (status != null) {
22+
23+
Integer statusCode = Integer.valueOf(status.toString());
24+
25+
if(statusCode == HttpStatus.NOT_FOUND.value()) {
26+
return "error-404";
27+
}
28+
else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
29+
return "error-500";
30+
}
3031
}
32+
return "error";
3133
}
3234

3335
@Override
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<!DOCTYPE html>
22
<html>
3+
<head>
4+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
6+
</head>
37
<body>
4-
<h1>Sorry we couldn't find the resource you are looking for</h1>
5-
<a href="/">Go Home</a>
8+
<div class="container">
9+
<div class="jumbotron" >
10+
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, we couldn't find the page you were looking for. </h1>
11+
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
12+
</div></div>
613
</body>
7-
</html>
14+
</html>
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
<!DOCTYPE html>
22
<html>
3+
<head>
4+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
6+
</head>
37
<body>
4-
<h1>Oops! We spilled something but we're fixing it</h1>
5-
<a href="/">Go Home</a>
8+
<div class="container">
9+
<div class="jumbotron" >
10+
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, something went wrong! </h1>
11+
12+
<h2 class="text-center">We're fixing it.</h2>
13+
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
14+
</div></div>
615
</body>
7-
</html>
16+
</html>
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
<!DOCTYPE html>
22
<html>
3+
<head>
4+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
6+
</head>
37
<body>
4-
<h1>Something went wrong! Our Engineers are on it temp</h1>
5-
<a href="/">Go Home</a>
8+
<div class="container">
9+
<div class="jumbotron" >
10+
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Something went wrong! </h1>
11+
12+
<h2 class="text-center">Our Engineers are on it.</h2>
13+
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
14+
</div></div>
615
</body>
716
</html>

‎spring-boot/src/main/resources/templates/index.ftl‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)