図書貸出処理→図書貸出確認ポップアップ→社内図書一覧に戻る処理作成

This commit is contained in:
2026-09-18 13:29:13 +09:00
parent 9ae5cecd61
commit 8c9f9ad4cd
5 changed files with 41 additions and 8 deletions

View File

@@ -3,12 +3,12 @@ package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class Book {
public class BookController {
@GetMapping("/book")
public String book() {
// HTMLテンプレートに welcome-spring.html を指定
return "book";
}
}

View File

@@ -3,10 +3,9 @@ package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class BookLend {
public class BookLendController {
@PostMapping("/bookLend")
public String welcome() {
// HTMLテンプレートに welcome-spring.html を指定
return "bookLend";
}

View File

@@ -0,0 +1,13 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class BookLendReturnController {
@PostMapping("/bookLendConfirmation")
public String bookLendConfirmation() {
return "book";
}
}

View File

@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<title>社内図書一覧</title>
</head>
<body>
<form method="post" action="bookLend">
@@ -10,7 +10,7 @@
<button type="submit" class="btn-login">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/></svg>
画面遷移テスト
貸出
</button>
</form>

View File

@@ -2,10 +2,31 @@
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<title>図書貸出処理</title>
</head>
<body>
成功
図書貸出処理
<form id="loanForm"action="bookLendConfirmation" method="post">
<div class="button-area">
<div class="right-buttons">
<button type="button" class="btn btn-primary"
onclick="submitLoan()">貸出する</button>
</div>
</div>
</form>
<script>
function submitLoan() {
if (confirm('この図書を貸出しますか?')) {
// OK選択時にフォーム送信を実行し、BookLendReturnControllerに処理を投げる
document.getElementById('loanForm').submit();
}
}
</script>
</body>
</html>