import java.util.Date;import javax.servlet.http.HttpSession;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;//监听器[用于监听HttpSesison产生和销毁]public class MyHttpSessionListener implements HttpSessionListener { //产生 public void sessionCreated(HttpSessionEvent se) { HttpSession session = se.getSession(); System.out.println(session.getId()); System.out.println("sessionCreated()" + new Date().toLocaleString()); } //销毁 public void sessionDestroyed(HttpSessionEvent se) { HttpSession session = se.getSession(); System.out.println(session.getId()); System.out.println("sessionDestroyed()"); System.out.println("sessionCreated()" + new Date().toLocaleString()); }} <listener> <listener-class>cn.xijie.listener.MyHttpSessionListener</listener-class> </listener> <session-config> <session-timeout>1</session-timeout> </session-config>
四月 20, 2018 1:38:46 下午 org.apache.catalina.startup.HostConfig reload
信息: Reloading context [/day04]
四月 20, 2018 1:38:46 下午 org.apache.catalina.core.StandardContext reload
信息: Reloading Context with name [/day04] has started
四月 20, 2018 1:38:47 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
四月 20, 2018 1:38:47 下午 org.apache.catalina.core.StandardContext reload
信息: Reloading Context with name [/day04] is completed
0CA6AE9F6B63E1BFADABA7B3091BA50A
sessionCreated()2018-4-20 13:39:03
共同学习,写下你的评论
评论加载中...
作者其他优质文章