Tomcat
javadoc说:
“Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.
Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.“
所以,根据javadoc的说法,你的问题的答案是(应该):
Q: Does calling HttpServletRequest.getSession(boolean create) cause the last accessed time of the session to be updated?
答:根据javadoc,没有(但见下文)
Q: What about getId() method or even calling getLastaccessedtime().
答:没有.
Q: In brief, what is the criteria of accessing the HttpSession that cause the getLastAccessedTime to be updated.
答:见上文.它记录上次客户端请求的时间.
请注意,实际行为可能取决于Servlet的实现.例如,根据Tomcat 7源代码(7.0.39.2),getSession(boolean)调用将更新访问时间:
>当当前会话尚未缓存在请求中时,请求的会话管理器能够将会话ID映射到有效会话,或者
>当create为true且创建会话时.
目前尚不清楚方案1是否真的可以在应用程序代码的调用中发生,但方案2当然可以.这意味着创建会话计为“访问”……这是有道理的.