标签:init spring pre pack ffffff override vax family tco
MyServletContextListener.java
package com.zns.listener; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; @WebListener public class MyServletContextListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { System.out.println("ServletContex初始化"); } @Override public void contextDestroyed(ServletContextEvent event) { System.out.println("ServletContex销毁"); } }
MyHttpSessionListener.java
package com.zns.listener; import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; /** * 监听Session的创建与销毁 * */ @WebListener public class MyHttpSessionListener implements HttpSessionListener { @Override public void sessionCreated(HttpSessionEvent event) { System.out.println("Session被创建"); } @Override public void sessionDestroyed(HttpSessionEvent event) { System.out.println("Session被销毁"); } }
在启动类增加@ServletComponentScan注解
标签:init spring pre pack ffffff override vax family tco
原文地址:https://www.cnblogs.com/zengnansheng/p/10389791.html