구현 된 클래스 HttpSessionListener
이 web.xml
에 등록되었으며 응용 프로그램이 시작될 때 sessionCreated()
메서드가 두 번 호출되는 중입니다. 응용 프로그램에서 로그 아웃 할 때 sessionDestroyed()
이 전화를 걸고 다시 시도한 후 sessionCreated()
이 전화를 겁니다. 왜 그런가?Spring MVC 응용 프로그램이 시작될 때 HttpSessionListener.sessionCreated()가 두 번 호출 됨
public class SessionManager implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
System.out.println("Session Creation called!!..");
}
@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
System.out.println("Session Destruction called!!..");
}
}
출력 :
응용 프로그램을 시작, 그것은 인쇄 "세션 창조라고! ..."두 번. 로그 아웃 할 때, 처음에는 "Session Destruction called !!"이 인쇄되고 두 번째는 "Session Creation called ... !!"으로 인쇄됩니다.
새 세션 생성시'sessionCreated()'메소드가 호출됩니다. 그래서 당신이 로그 아웃 할 때'session.invalidate()'가 호출되고 나면 announouns user를 위해 새로운 세션이 생성됩니다. – zombie
이런 식으로해서는 안됩니다. 내가 잘못 가고있는 곳에서 나를 도울 수 있니? – Tijom