Browse Source
added custom error page and birth and death restapiservices url added for fetching records
master
added custom error page and birth and death restapiservices url added for fetching records
master
7 changed files with 703 additions and 208 deletions
-
136src/main/java/com/gcc/crslogs/controller/ApiController.java
-
43src/main/java/com/gcc/crslogs/controller/CustomErrorController.java
-
11src/main/java/com/gcc/crslogs/controller/MainController.java
-
160src/main/java/com/gcc/crslogs/service/BirthAndDeathDetailsService.java
-
352src/main/resources/templates/modules/crslogspages/birth.html
-
160src/main/resources/templates/modules/crslogspages/death.html
-
49src/main/resources/templates/modules/crslogspages/message.html
@ -0,0 +1,43 @@ |
|||||
|
package com.gcc.crslogs.controller; |
||||
|
|
||||
|
import org.springframework.boot.web.servlet.error.ErrorController; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.ui.Model; |
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
|
||||
|
@Controller |
||||
|
public class CustomErrorController implements ErrorController { |
||||
|
@RequestMapping("/error") |
||||
|
public String handleError(HttpServletRequest request, Model model) { |
||||
|
Integer statusCode = (Integer) request.getAttribute("jakarta.servlet.error.status_code"); |
||||
|
String title = "Error"; |
||||
|
String message = "An unexpected error occurred."; |
||||
|
String code = statusCode != null ? statusCode.toString() : ""; |
||||
|
|
||||
|
if (statusCode != null) { |
||||
|
switch (statusCode) { |
||||
|
case 404: |
||||
|
title = "Page Not Found"; |
||||
|
message = "Sorry, the page you are looking for does not exist."; |
||||
|
break; |
||||
|
case 403: |
||||
|
title = "Access Forbidden"; |
||||
|
message = "You do not have permission to access this page."; |
||||
|
break; |
||||
|
case 500: |
||||
|
title = "Internal Server Error"; |
||||
|
message = "Oops! Something went wrong on our end."; |
||||
|
break; |
||||
|
default: |
||||
|
title = "Error"; |
||||
|
message = "An unexpected error occurred."; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
model.addAttribute("code", code); |
||||
|
model.addAttribute("title", title); |
||||
|
model.addAttribute("message", message); |
||||
|
return "modules/crslogspages/message"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<title th:text="${title} ?: 'Message'">Message</title> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<style> |
||||
|
body { background: #f8fafc; color: #333; font-family: 'Segoe UI', Arial, sans-serif; margin: 0; } |
||||
|
.center-box { |
||||
|
max-width: 400px; |
||||
|
margin: 80px auto; |
||||
|
background: #fff; |
||||
|
border-radius: 12px; |
||||
|
box-shadow: 0 2px 16px #0001; |
||||
|
padding: 40px 30px 30px 30px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
.center-box h1 { font-size: 3rem; color: #007bff; margin: 0 0 10px 0; } |
||||
|
.center-box h2 { font-size: 1.5rem; margin: 0 0 10px 0; } |
||||
|
.center-box p { color: #666; margin-bottom: 30px; } |
||||
|
.btn-home { |
||||
|
display: inline-block; |
||||
|
background: #007bff; |
||||
|
color: #fff; |
||||
|
padding: 12px 32px; |
||||
|
border-radius: 6px; |
||||
|
text-decoration: none; |
||||
|
font-size: 1.1rem; |
||||
|
transition: background 0.2s; |
||||
|
} |
||||
|
.btn-home:hover { background: #0056b3; } |
||||
|
@media (max-width: 600px) { |
||||
|
.center-box { padding: 25px 10px; } |
||||
|
.center-box h1 { font-size: 2rem; } |
||||
|
} |
||||
|
</style> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div class="center-box"> |
||||
|
<h1 th:text="${code} ?: 'Info'">Info</h1> |
||||
|
<h2 th:text="${title} ?: 'Message'">Message</h2> |
||||
|
<p th:text="${message} ?: 'No details provided.'">No details provided.</p> |
||||
|
<a href="/crs/birthloginpage" class="btn-home">Go to Home</a> |
||||
|
</div> |
||||
|
<script> |
||||
|
setTimeout(() => { window.location.href = '/crs/birthloginpage'; }, 10000); |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue