生命周期监听: ServletContextListener,它有两个方法,一个在出生时调用,一个在死亡时调用;
void contextInitialized(ServletContextEvent sce):创建 Servletcontext 时
void contextDestroyed(ServletContextEvent sce):销毁 Servletcontext 时
属性监听: ServletContextAttributeListener,它有三个方法,一个在添加属性时调用,一个在替换属性时调用,最后一个是在移除属性时调用。
HttpSession生命周期监听:HttpSessionListener,它有两个方法,一个在出生时调用,一个在死亡时调用;
void sessionCreated( HttpSessionEvent se):创建 session 时
void sessionDestoryed( HttpSessionEvent se):销毁 session 时
属性监听:HttpSessionAttributeListener,它有三个方法,一个在添加属性时调用,一个在替换属性时调用,最后一个是在移除属性时调用;
void attributeAdded(HttpSessionBindingEvent event);
void attributeRemoved(HttpSessionBindingEvent event);
void attributeReplaced(HttpSessionBindingEvent event);
生命周期监听:ServletRequestListener,它有两个方法,一个在出生时调用,一个在死亡时调用;
void requestlnitialized(ServletRequestEvent sre):创建 request 时
void requestDestoryed (ServletRequestEvent sre):销毁 request 时
属性监听: ServletRequestAttributeListener,它有三个方法,一个在添加属性时调用,一个在替换属性时调用,最后一个是在移除属性时调用。
void attributeAdded(ServletRequestAttributeEvent srae);
void attributeRemoved(ServletRequestAttributeEvent srae);
void attributeReplaced(ServletRequestAttributeEvent srae);
写一个监听器类,要求必须去实现某个监听器接口;
注册,是在 web.xml 中配置来完成注册(cn.a.d.f.MyListener);
SerxletContextExent:
- ServletContext getServletContext()
HttpSessionExent :
- HttpSession getSession()
ServletReguest :
-
ServletContext getSerxletContext()
-
ServletRegues getSerxletReguest()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)