This commit is contained in:
y-kumaki
2026-09-18 13:30:39 +09:00
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.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@Controller @Controller
public class Book { public class BookController {
@GetMapping("/book") @GetMapping("/book")
public String book() { public String book() {
// HTMLテンプレートに welcome-spring.html を指定
return "book"; return "book";
} }
} }

View File

@@ -3,10 +3,9 @@ package com.example.demo.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@Controller @Controller
public class BookLend { public class BookLendController {
@PostMapping("/bookLend") @PostMapping("/bookLend")
public String welcome() { public String welcome() {
// HTMLテンプレートに welcome-spring.html を指定
return "bookLend"; 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> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Insert title here</title> <title>社内図書一覧</title>
</head> </head>
<body> <body>
<form method="post" action="bookLend"> <form method="post" action="bookLend">
@@ -10,7 +10,7 @@
<button type="submit" class="btn-login"> <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> <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> </button>
</form> </form>

View File

@@ -2,10 +2,31 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Insert title here</title> <title>図書貸出処理</title>
</head> </head>
<body> <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> </body>
</html> </html>