我正在使用上下文来共享登录 session 。我使用 setAttibute 函数。 我知道 HttpSession 具有设置最大超时时间的属性。
是否可以以类似的方式设置上下文属性?
ServletContext context = httpservlet.getServletContext();
context.setAttribute("currentSessionUser", username);
谢谢
最佳答案
不要那样做。上下文是应用程序范围内的,当多个用户浏览您的网站时,您会得到非常意外的结果。
关于java - 是否可以设置 ServletContext 超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5014188/