25 监听器Listener——ServletContext监听器
ServletContext监听器
有关信息请跳转这里
两个接口
ServletContextListener:监听servletContextListener对象的创建和销毁
ServletContextAttributeListener:监听servletContextListener对象里的数据的增删改
示例:
public class Listener implements ServletContextListener,ServletContextAttributeListener{ /*------------------------application监听器-----------------------------------------*/ @Override public void attributeAdded(ServletContextAttributeEvent event) { // TODO Auto-generated method stub } @Override public void attributeRemoved(ServletContextAttributeEvent event) { // TODO Auto-generated method stub } @Override public void attributeReplaced(ServletContextAttributeEvent event) { // TODO Auto-generated method stub } @Override public void contextDestroyed(ServletContextEvent sce) { // TODO Auto-generated method stub } @Override public void contextInitialized(ServletContextEvent sce) { // TODO Auto-generated method stub } }