servlet context listener
发表于:2024-11-24 作者:热门IT资讯网编辑
编辑最后更新 2024年11月24日,ServletContextListener@WebListenerpublic class ServletContextListenerDemo implements ServletContextL
ServletContextListener
@WebListenerpublic class ServletContextListenerDemo implements ServletContextListener{ @Override public void contextInitialized(ServletContextEvent servletContextEvent) { } @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { }}
ServletContextAttributeListener
@WebListenerpublic class ServletContextAttributeListenerDemo implements ServletContextAttributeListener { @Override public void attributeAdded(ServletContextAttributeEvent servletContextAttributeEvent) { } @Override public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent) { } @Override public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent) { }}
说明:servletContext上下文监听器,是整个应用在启动的时候加载的context.一个web application只会有一个context.因此,servletContext是对整个appliction全程有效的。