Spring boot Security redirect 정보 가져오기

2024. 7. 29. 22:49Java/Spring Boot Security

	@RequestMapping("/login")
	public String login(HttpServletRequest request, HttpServletResponse response) {
        // case1
        HttpSession session = request.getSession();
		log.debug(session.getAttribute("SPRING_SECURITY_SAVED_REQUEST"));
        
        // case2
		RequestCache requestCache = new HttpSessionRequestCache();
		SavedRequest savedRequest = requestCache.getRequest(request, response);
		log.debug(savedRequest.getRedirectUrl());
		return "login";
	}