鎬庝箞璁剧疆session鏈夋晥鏃堕棿
Session鐨勬湁鏁堟椂闂村彲浠ラ€氳繃鍦╳eb搴旂敤鐨勯厤缃枃浠朵腑杩涜璁剧疆銆傚叿浣撶殑璁剧疆鏂瑰紡鍙兘浼氬洜浣跨敤鐨剋eb寮€鍙戞鏋惰€屾湁鎵€涓嶅悓锛屼互涓嬫槸涓€浜涘父瑙佺殑璁剧疆鏂瑰紡锛?/p>
-
鍦╳eb.xml涓娇鐢?session-config>鏍囩杩涜璁剧疆锛?/p>
<session-config> <session-timeout>30</session-timeout> </session-config>
涓婅堪浠g爜灏嗕細灏唖ession鐨勬湁鏁堟椂闂磋缃负30鍒嗛挓銆?/p>
-
浣跨敤Servlet涓殑setMaxInactiveInterval鏂规硶杩涜璁剧疆锛?/p>
HttpSession session = request.getSession(); session.setMaxInactiveInterval(1800); // 璁剧疆session鐨勬湁鏁堟椂闂翠负1800绉掞紙30鍒嗛挓锛?/span>
-
浣跨敤妗嗘灦鎻愪緵鐨勯厤缃枃浠惰繘琛岃缃紝渚嬪鍦⊿pring MVC妗嗘灦涓紝鍙互鍦╝pplication.properties鎴朼pplication.yml鏂囦欢涓繘琛岄厤缃細
-
application.properties锛?/p>
server.servlet.session.timeout=1800
-
application.yml锛?/p>
server: servlet: session: timeout: 1800
-
璇锋牴鎹嚜宸变娇鐢ㄧ殑鍏蜂綋寮€鍙戞鏋惰繘琛岀浉搴旂殑璁剧疆銆?/p>
相关问答