Spring
컨트롤러 아닌곳에서 session 값 얻기
natrue
2021. 11. 28. 14:09
728x90
public static LoginVO getUser(){
ServletRequestAttributes servletrequestattributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpSession session = servletrequestattributes.getRequest().getSession(true);
return (LoginVO) session.getAttribute("컨트롤러에서 만들었던 setAttribute 값 ex)loginVO");
}