本文實例講述了java設置session過期時間的實現方法,分享給大家供大家參考。具體實現方法如下:
1、Timeout in the deployment descriptor (web.xml)
以分鐘為單位
2、Timeout with setMaxInactiveInterval()
通過編碼方式,指定特定的session的過期時間,以秒為單位。例如:
Thoughts….
This is a bit confusing , the value in deployment descriptor (web.xml) is in “minute”, but the setMaxInactiveInterval() method is accept the value in “second”. Both functions should synchronize it in future release
3、在程序中定義,單位為秒,設置為-1表示永不過期,示例代碼為:
希望本文所述對大家的Java程序設計有所幫助。
新聞熱點
疑難解答