Вопрос

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