欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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);//单位为秒
        }