From efdaacbb27c051665e9e6d09bc3546e5887e5b53 Mon Sep 17 00:00:00 2001 From: s-choi Date: Mon, 28 Sep 2026 15:51:16 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E3=82=A8=E3=83=A9=E3=83=BC=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=A7=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E5=BB=83=E6=A3=84=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/aop/handler/GlobalExceptionHandler.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java b/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java index c8fc40a..830c07b 100644 --- a/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java @@ -4,6 +4,8 @@ package com.example.demo.aop.handler; import java.util.logging.Level; import java.util.logging.Logger; +import jakarta.servlet.http.HttpSession; + import org.springframework.http.HttpStatus; import org.springframework.ui.Model; import org.springframework.web.HttpRequestMethodNotSupportedException; @@ -37,25 +39,31 @@ public class GlobalExceptionHandler { } @ExceptionHandler(HttpRequestMethodNotSupportedException.class) - public String handleBadRequestException(Model model, Exception e) { + public String handleBadRequestException(Model model, Exception e, HttpSession session) { model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST); model.addAttribute("status", HttpStatus.BAD_REQUEST.value()); e.printStackTrace(); LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e); + + System.out.println("session invalidated"); + session.invalidate(); return "error"; } @ExceptionHandler(Exception.class) - public String AllException(Model model, Exception e) { + public String AllException(Model model, Exception e, HttpSession session) { model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST); e.printStackTrace(); LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e); + System.out.println("session invalidated"); + session.invalidate(); + return "error"; } }