我正在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);
}
如果用戶想繼續會話,您是否正確的方法,請分享精確答案代碼 –