WebLogic如何设置session超时时间
1、web.xml
设置WEB应用程序描述符web.xml里的<session-timeout>元素。这个值以分钟为单位,并覆盖weblogic.xml中的TimeoutSecs属性
<session-config>
<session-timeout>60</session-timeout>
</session-config>
此例表示Session将在60分钟后过期
当<session-timeout>设置为-2,表示将使用在weblogic.xml中设置的TimeoutSecs这个属性值。
当<session-timeout>设置为-1,表示Session将永不过期,而忽略在weblogic.xml中设置的TimeoutSecs属性值。
该属性值可以通过console控制台来设置
2、weblogic.xml
设置WebLogic特有部署描述符weblogic.xml的<session-descriptor>元素的TimeoutSecs属性。这个值以秒为单位
<session-descriptor>
<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>3600</param-value>
</session-param>
</session-descriptor>
默认值是3600
3、jsp中控制
session.setmaxinactiveinterval(7200);
session是默认对象,可以直接引用,单位秒s
4、servlet中控制
httpsession session = request.getsession();
session.setmaxinactiveinterval(7200);
单位秒s
如果使用WEBLOGIC作为应用服务器,设置SESSION超时时间会选择在WEBLOGIC的控制台设定。实际上,WEBLOGIC是将超时设定保存在WEB-INF下的weblogic.xml中,格式如下:
<session-descriptor>
<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>7200</param-value>
</session-param>
</session-descriptor>
param-value中的数值就是超时时间,单位为秒。在设置完这个参数后,会发现超时时间并一定起效。这是为什么呢?
原来在WEB-INF下还有一个配置文件web.xml,里面同样会有一段设置session,格式如下:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
session-timeout中的值也是超时时间,单位为分钟。
如果在两个文件中同时设置了超时时间,则会以web.xml中为准。
所以在weblogic环境中,最好将web.xml中关于超时的设置删掉,保持唯一性。
web.xml的session-timeout设为-1,问题解决;
设置WEB应用程序描述符web.xml里的<session-timeout>元素。这个值以分钟为单位,并覆盖weblogic.xml中的TimeoutSecs属性
<session-config>
<session-timeout>60</session-timeout>
</session-config>
此例表示Session将在60分钟后过期
当<session-timeout>设置为-2,表示将使用在weblogic.xml中设置的TimeoutSecs这个属性值。
当<session-timeout>设置为-1,表示Session将永不过期,而忽略在weblogic.xml中设置的TimeoutSecs属性值。
该属性值可以通过console控制台来设置
2、weblogic.xml
设置WebLogic特有部署描述符weblogic.xml的<session-descriptor>元素的TimeoutSecs属性。这个值以秒为单位
<session-descriptor>
<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>3600</param-value>
</session-param>
</session-descriptor>
默认值是3600
3、jsp中控制
session.setmaxinactiveinterval(7200);
session是默认对象,可以直接引用,单位秒s
4、servlet中控制
httpsession session = request.getsession();
session.setmaxinactiveinterval(7200);
单位秒s
如果使用WEBLOGIC作为应用服务器,设置SESSION超时时间会选择在WEBLOGIC的控制台设定。实际上,WEBLOGIC是将超时设定保存在WEB-INF下的weblogic.xml中,格式如下:
<session-descriptor>
<session-param>
<param-name>TimeoutSecs</param-name>
<param-value>7200</param-value>
</session-param>
</session-descriptor>
param-value中的数值就是超时时间,单位为秒。在设置完这个参数后,会发现超时时间并一定起效。这是为什么呢?
原来在WEB-INF下还有一个配置文件web.xml,里面同样会有一段设置session,格式如下:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
session-timeout中的值也是超时时间,单位为分钟。
如果在两个文件中同时设置了超时时间,则会以web.xml中为准。
所以在weblogic环境中,最好将web.xml中关于超时的设置删掉,保持唯一性。
web.xml的session-timeout设为-1,问题解决;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2013-11-21 《博客园精华集--Sharepoint分册》第三轮结果(转)
2013-11-21 《博客园精华集》Sharepoint+MOSS分册第2轮筛选结果文章列表 (转)