diff --git a/app/src/main/java/com/techcourse/DispatcherServletInitializer.java b/app/src/main/java/com/techcourse/DispatcherServletInitializer.java index 610f865c6f..4e18625a40 100644 --- a/app/src/main/java/com/techcourse/DispatcherServletInitializer.java +++ b/app/src/main/java/com/techcourse/DispatcherServletInitializer.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import web.org.springframework.web.WebApplicationInitializer; +import webmvc.org.springframework.web.servlet.mvc.DispatcherServlet; import webmvc.org.springframework.web.servlet.mvc.tobe.AnnotationHandlerMapping; import webmvc.org.springframework.web.servlet.mvc.tobe.HandlerExecutionHandlerAdapter; diff --git a/app/src/main/java/com/techcourse/controller/LogoutController.java b/app/src/main/java/com/techcourse/controller/LogoutController.java index 26c1320e62..f9c39099be 100644 --- a/app/src/main/java/com/techcourse/controller/LogoutController.java +++ b/app/src/main/java/com/techcourse/controller/LogoutController.java @@ -11,9 +11,8 @@ @Controller public class LogoutController { - @RequestMapping(value = "/logout", method = RequestMethod.POST) - public ModelAndView logout(final HttpServletRequest request, - final HttpServletResponse response) { + @RequestMapping(value = "/logout", method = RequestMethod.GET) + public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) { final var session = request.getSession(); session.removeAttribute(UserSession.SESSION_KEY); return new ModelAndView(new JspView("redirect:/")); diff --git a/app/src/main/java/com/techcourse/DispatcherServlet.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/DispatcherServlet.java similarity index 92% rename from app/src/main/java/com/techcourse/DispatcherServlet.java rename to mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/DispatcherServlet.java index 10e0b3b4fb..568dbf505f 100644 --- a/app/src/main/java/com/techcourse/DispatcherServlet.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/DispatcherServlet.java @@ -1,4 +1,4 @@ -package com.techcourse; +package webmvc.org.springframework.web.servlet.mvc; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; @@ -8,8 +8,6 @@ import org.slf4j.LoggerFactory; import webmvc.org.springframework.web.servlet.ModelAndView; import webmvc.org.springframework.web.servlet.View; -import webmvc.org.springframework.web.servlet.mvc.HandlerAdapter; -import webmvc.org.springframework.web.servlet.mvc.HandlerMapping; public class DispatcherServlet extends HttpServlet { diff --git a/app/src/main/java/com/techcourse/HandlerAdapters.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/HandlerAdapters.java similarity index 81% rename from app/src/main/java/com/techcourse/HandlerAdapters.java rename to mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/HandlerAdapters.java index 1cb824de1f..3f35034ba4 100644 --- a/app/src/main/java/com/techcourse/HandlerAdapters.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/HandlerAdapters.java @@ -1,7 +1,4 @@ -package com.techcourse; - -import jakarta.annotation.Nonnull; -import webmvc.org.springframework.web.servlet.mvc.HandlerAdapter; +package webmvc.org.springframework.web.servlet.mvc; import java.util.ArrayList; import java.util.List; @@ -14,7 +11,6 @@ public void addHandlerAdapter(HandlerAdapter handlerAdapter) { handlerAdapters.add(handlerAdapter); } - @Nonnull public HandlerAdapter getHandlerAdapter(Object handler) { return handlerAdapters.stream() .filter(adapter -> adapter.supports(handler)) diff --git a/app/src/main/java/com/techcourse/HandlerMappings.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/HandlerMappings.java similarity index 86% rename from app/src/main/java/com/techcourse/HandlerMappings.java rename to mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/HandlerMappings.java index 32591b4929..8773063799 100644 --- a/app/src/main/java/com/techcourse/HandlerMappings.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/HandlerMappings.java @@ -1,8 +1,6 @@ -package com.techcourse; +package webmvc.org.springframework.web.servlet.mvc; -import jakarta.annotation.Nonnull; import jakarta.servlet.http.HttpServletRequest; -import webmvc.org.springframework.web.servlet.mvc.HandlerMapping; import java.util.ArrayList; import java.util.List; @@ -16,7 +14,6 @@ public void initializeEach() { handlerMappings.forEach(HandlerMapping::initialize); } - @Nonnull public Object getHandler(HttpServletRequest request) { return handlerMappings.stream() .map(handlerMapping -> handlerMapping.getHandler(request))