From 4a01b85ae9487f5980b4091ef5efa1ed89def490 Mon Sep 17 00:00:00 2001 From: m-shimizu <26-m-e-stella-tecnica@it-college.jp> Date: Tue, 20 Oct 2026 10:44:04 +0900 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E4=BD=93=E5=8F=8D=E6=98=A0=E3=81=AA?= =?UTF-8?q?=E3=81=97=5FFR-01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- book-rent/pom.xml | 126 +++++++++++++++++- .../demo/controller/MenuController.java | 28 ++-- .../src/main/resources/application.properties | 13 ++ .../src/main/resources/templates/menu.html | 3 +- 4 files changed, 160 insertions(+), 10 deletions(-) diff --git a/book-rent/pom.xml b/book-rent/pom.xml index 139597f..565f780 100644 --- a/book-rent/pom.xml +++ b/book-rent/pom.xml @@ -1,2 +1,126 @@ - + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 4.1.1 + + + com.example + book-rent + 0.0.1-SNAPSHOT + war + book-rent + + + + + + + + + + + + + + + + 21 + + + +org.springframework.boot +spring-boot-starter-data-jpa + + +org.springframework.boot +spring-boot-starter-thymeleaf + + +org.springframework.boot +spring-boot-starter-validation + + + +org.springframework.boot +spring-boot-starter-web + + + +org.springframework.boot +spring-devtools +runtime +true + + +com.mysql +mysql-connector-j +runtime + + +org.projectlombok +lombok +true + + +org.springframework.boot +spring-boot-starter-tomcat +provided + + + +org.springframework.boot +spring-boot-starter-test +test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + compile + + compile + + + + + org.projectlombok + lombok + + + + + + default-testCompile + test-compile + + testCompile + + + + + org.projectlombok + lombok + + + + + + + + + + diff --git a/book-rent/src/main/java/com/example/demo/controller/MenuController.java b/book-rent/src/main/java/com/example/demo/controller/MenuController.java index a84e905..d1c373c 100644 --- a/book-rent/src/main/java/com/example/demo/controller/MenuController.java +++ b/book-rent/src/main/java/com/example/demo/controller/MenuController.java @@ -1,19 +1,31 @@ package com.example.demo.controller; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; + import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; @Controller public class MenuController { + // メニュー画面表示 @GetMapping("/menu") - public String showMenu(Model model) { - - // 仮のログインユーザー名 - model.addAttribute("loginUserName", "テストユーザー"); - - // menu.htmlを表示 + public String showMenu() { return "menu"; } -} + + // ログアウト処理 + @PostMapping("/logout") + public String logout(HttpServletRequest request) { + + HttpSession session = request.getSession(false); + + if (session != null) { + session.invalidate(); + } + + return "redirect:/login"; + } +} \ No newline at end of file diff --git a/book-rent/src/main/resources/application.properties b/book-rent/src/main/resources/application.properties index e69de29..93d885f 100644 --- a/book-rent/src/main/resources/application.properties +++ b/book-rent/src/main/resources/application.properties @@ -0,0 +1,13 @@ +spring.application.name=book-rent +# --- MySQL (CREATE DATABASE.sql で作成した book_manage) --- +spring.datasource.url=jdbc:mysql://localhost:3306/book_manage?serverTimezone=Asia/Tokyo&characterEncoding=UTF-8 +spring.datasource.username=bookuser +spring.datasource.password=Book2026 + +# テーブルはSQLで作成済み。JPAでは変更しない +spring.jpa.hibernate.ddl-auto=none +spring.jpa.open-in-view=false +spring.jpa.properties.hibernate.jdbc.time_zone=Asia/Tokyo + +spring.thymeleaf.cache=false +server.servlet.session.timeout=30m diff --git a/book-rent/src/main/resources/templates/menu.html b/book-rent/src/main/resources/templates/menu.html index ff60b1b..e5a6d92 100644 --- a/book-rent/src/main/resources/templates/menu.html +++ b/book-rent/src/main/resources/templates/menu.html @@ -10,7 +10,8 @@
-

メニュー

+

書籍管理システム

+

メニュー