JAVA设置session超时失效的几种方式
程序员文章站
2024-03-20 18:16:10
...
① 在Web容器中设置(Tomcat)
在tomcat/conf/web.xml中找到如下代码 ,单位min
<session-config>
<session-timeout>30</session-timeout>
</session-config>
② 普通sm项目配置同上,找到项目中的web.xml
③ springboot中配置,我用的是application.yml,单位秒
中增加server.session.timeout:300
④ 直接在java代码中设置
public void getRandcode(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
session.setMaxInactiveInterval(5*60);//单位为秒
}