简体   繁体   中英

Redirect to login on session timeout in spring

I have a multi-page web application, it uses iframe to handle the current page, and at the top I have the navigator.

The problem is, when the user become idle and the session timeout. The page continues as "logged" state. When the user tries to interact with the iframe page (current page) the server redirect the iframe page to the login page and the navigator continues in the top.

How can I redirect the entire page to the login?

Can I use websockets to the server send back a message informing that the session timeout and than redirect to login?

您可以像这样重定向iframe的父项:

parent.document.location.href = 'http://...'

If the login page is implemented by yourself (eg not by spring-security), you can add a piece of JavaScript code on the page to conditionally break out of the iframe:

<script type="text/javascript">
if (top.location!= self.location) {
   top.location = self.location.href;
}
</script>

There's no need to interact with the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM