监听器
1.概念
(1)本身是一个对象
(2)监听其他对象
(3)响应其他对象
2.用途
(1)统计在线人数和在线用户
(2)系统启动时加载初始化信息
(3)统计网站访问量
(4)跟Spring结合的操作
3.启动顺序
(1)多个监听器:按注册顺序
(2)优先级:监听器>过滤器>Servlet
4.分类
4.1按监听对象:
(1)ServletContextListener接口
(2)HttpSessionListener接口
(3)ServletRequestListener接口
方法:initial()/destroyed()
4.2按对象属性:
(1)ServletContextAttributeListener接口
(2)HttpSessionAttributeListener接口
(3)ServletRequestAttributeListener接口
方法: attributeAdded()/attributeRemoved()/attributeReplaced