问题
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.
- 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)
- What is the meta tag which I need to place in my *.xhtml which will direct to the login page?
Hope the requirement is clear. Just stating the requirements of my problem again
- System should not invalid the session as far as the user is interacting with the system.
- 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.
回答1:
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.
来源:https://stackoverflow.com/questions/29246535/redirecting-to-login-when-session-timeout-in-jsf-spring-or-automatic-logout-when