在JSF/Spring中会话超时时重定向到登录,或者在会话停用时(或给定时间为idel)自动注销 [英] Redirecting to login when session timeout in JSF/Spring or automatic logout when session deactivate(or idel for a given time)

查看:101
本文介绍了在JSF/Spring中会话超时时重定向到登录,或者在会话停用时(或给定时间为idel)自动注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用JSF和Spring 3.x的J2EE应用程序.我的Web应用程序是使用* .xhtml开发的,并且我使用了JSF ManagedBeans. 会话经过超时后,我想重定向到登录页面.我有点新,需要了解以下内容.

I have a J2EE application which uses JSF and Spring 3.x. My web app is developed in *.xhtml, and I have used JSF ManagedBeans. I want to redirect to login page when the session has elapsed the timeoout. I am bit new and need to know the following.

  1. 如何设置会话超时时间(基本上我想设置一个最大时间,在该时间应用程序将处于空闲状态,并使用无效的会话重定向到登录页面)
  2. 我需要将什么放置在* .xhtml中的meta标记中,以将其定向到登录页面?

希望这个要求很明确.只是再次说明我的问题的要求

Hope the requirement is clear. Just stating the requirements of my problem again

  1. 只要用户与系统进行交互,系统就不应使会话无效.
  2. 仅当系统闲置给定时间时,它才应使会话无效并重定向到登录页面.

技术栈 带有ManagedBeans的JSF(已使用face-config.xml等.) 服务层的春天 休眠DAO层并定义实体.

Tech Stack JSF with ManagedBeans(Have used face-config.xml etc..) Spring for the service layer Hibernate for the DAO layer and in defining the entities.

推荐答案

如果"idle"表示不向服务器发送任何请求,则必须设置

If by "idle" you mean not sending any request to the server then you have to set the session-timeout in your web.xml file. It should look like this for a 30 minutes timeout :

<session-config>
    <session-timeout>30</session-timeout>
</session-config>

要处理会话超时时登录的重定向,请查看此答案.

To handle the redirection to login when the session timeout have a look at this answer.

这篇关于在JSF/Spring中会话超时时重定向到登录,或者在会话停用时(或给定时间为idel)自动注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆