1、jsp頁面直接設置
// 設置秒數
session.setMaxInactiveInterval(10);
2、web.xml設置,會覆蓋tomcat下conf/web.xml的session-config設置
<session-config>
<!-- 配置session的超時管理,以分鐘爲單位 -->
<session-timeout>30</session-timeout>
</session-config>
3、如果服務器爲tomcat的話,則在conf/web.xml下修改
<session-config>
<!-- 配置session的超時管理,以分鐘爲單位 -->
<session-timeout>30</session-timeout>
</session-config>
注意優先級:1>2>3