Servlet常用监听接口

场景 监听接口 事件类型
你想知道一个web应用上下文中是否增加、删除或替换了一个属性

javax.servlet.ServletContextAttributeListener

attributeAdded

attributeRemoved

attributeReplaced

ServletContextAttributeEvent
你想知道有多少并发个用户。也就是说,你想跟踪活动的会话

javax.servlet.http.HttpSessionListener

sessionCreated

sessionDestroyed

HttpSessionEvent
每次请求到来时你都想知道,以便建立日志记录

javax.servlet.ServletRequestListener

requestInitialized

requestDestroyed

ServletRequestEvent
增加、删除或替换一个请求属性时你希望知道

javax.servlet.ServletRequestAttributeListener

attributeAdded

attributeRemoved

attributeReplaced

ServletRequestAttributeEvent
你有一个属性类(这个类表示的对象将放在一个属性中),而且你希望这个类型的对象在绑定到一个会话中或从会话中删除时得到通知

javax.servlet.http.HttpSessionBindingListener

valueBound

valueUnbound

HttpSessionBindingEvent
增加、删除或替换一个会话属性时你希望知道

javax.servlet.http.HttpSessionAttributeListener

attributeAdded

attributeRemoved

attributeReplaced

HttpSessionBindingEvent
你想知道是否创建或撤销了一个上下文

javax.servlet.ServletContextListener

contextInitialized

contextDestroyed

ServletContextEvent
你有一个属性类,而且希望这个类型的对象在其绑定的会话迁移到另一个JVM时得到通知

javax.servlet.http.HttpSessionActivationListener

sessionDidActivate

sessionWillPassivate

HttpSessionEvent

猜你喜欢

转载自www.cnblogs.com/suheng/p/9302519.html