Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into s-morimto
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.example.demo.app.presentation.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class ErrorController {
|
||||
@GetMapping("/error")
|
||||
public String showError() {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.demo.exception;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public String handleException(
|
||||
Exception e,
|
||||
Model model) {
|
||||
|
||||
model.addAttribute(
|
||||
"errorMessage",
|
||||
"システムエラーが発生しました。"
|
||||
+ "初めからやり直してください。");
|
||||
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
32
src/main/resources/templates/error.html
Normal file
32
src/main/resources/templates/error.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>エラー</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div th:replace="~{header :: header}">
|
||||
</div>
|
||||
|
||||
<div class="container text-center mt-5">
|
||||
|
||||
<h2 class="text-danger">
|
||||
エラーが発生しました
|
||||
</h2>
|
||||
|
||||
<p th:text="${errorMessage}"></p>
|
||||
|
||||
<a class="btn btn-primary" th:href="@{/login}">
|
||||
ログイン画面へ
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user