我正在JSF框架上工作。在Web.xml会话超时时间是5分钟。 4分钟后,我为用户显示确认对话框,以确定是否保持活动状态。点击Yes后,我尝试了sessionObject.setMaxInactiveInterval(5)。但会话在5分钟后失效。有没有办法在web.xml中不改变时间的情况下动态扩展用户会话时间。刷新会话时间,当用户确认保持联机时
public void refreshSession(){
//code to refresh the session
System.out.println("want to stay alive");
HttpSession currentSession = ServerUtility.getSession();
currentSession.setMaxInactiveInterval(2*60);
}
如果用户想继续会话,您是否正确的方法,请分享精确答案代码 –