简体   繁体   English

在JSF / Spring中会话超时时重定向到登录,或者在会话停用时(或在给定时间为idel时)自动注销

[英]Redirecting to login when session timeout in JSF/Spring or automatic logout when session deactivate(or idel for a given time)

I have a J2EE application which uses JSF and Spring 3.x. 我有一个使用JSF和Spring 3.x的J2EE应用程序。 My web app is developed in *.xhtml, and I have used JSF ManagedBeans. 我的Web应用程序是使用* .xhtml开发的,并且我使用了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. How to set the session timeout time(Basically I want to set a maximum time where the application would be idle and redirect to the login page with an invalid session) 如何设置会话超时时间(基本上,我想设置一个最大时间,在该时间应用程序将处于空闲状态,并使用无效的会话重定向到登录页面)
  2. What is the meta tag which I need to place in my *.xhtml which will direct to the login page? 我需要在* .xhtml中放置哪些元标记,该标记将定向到登录页面?

Hope the requirement is clear. 希望要求明确。 Just stating the requirements of my problem again 只是再次说明我的问题的要求

  1. System should not invalid the session as far as the user is interacting with the system. 只要用户与系统进行交互,系统就不应使会话无效。
  2. It Should only invalid the session and redirect to the login page when the system has been idle for a given time. 仅当系统闲置给定时间时,它才应使会话无效并重定向到登录页面。

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. 带有ManagedBeans的Tech Stack JSF(已使用face-config.xml等。)Spring用于服务层Hibernate用于DAO层并用于定义实体。

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. 如果通过“ idle”表示不向服务器发送任何请求,则必须在web.xml文件中设置session-timeout It should look like this for a 30 minutes timeout : 30分钟的超时时间应如下所示:

<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 . 要在会话超时时处理重定向登录,请查看此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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