문제

I am using spring mvc and storing some data in session. I want to delete those data when the user leave that menu and moved to next menu. I don't know where to code for it.

Also if the user is clicking other menu and if that page have any unsaved data, I want to get confirmation from the user.

Is jspDestroy() will help me for this.

Please help me.

도움이 되었습니까?

해결책

As from the various comments above your problem is little bit clear, you want to perform some action when user is leaving the current page.

You can use unload event

window.onunload = function(){
 //give ajax call here and remove whatever you want to remove from session
}

unload event

A user agent must dispatch this event when the DOM Implementation removes from the environment the resource (such as the document) or any dependent resources (such as images, style sheets, scripts). The document must be unloaded after the dispatch of this event type.

다른 팁

From the comments you want to remove some particular objects not all so you can use session.removeAttribute()

For removing all sessions use session.invalidate()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top