0
【笔记】Listener学习笔记
source link: https://feiju12138.github.io/2022/10/02/Listener%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
JavaWeb中的Listener(监听器)学习笔记
定义一个Listener类
- 实现对应的接口,重写所有抽象方法,类上添加注解
@WebListener
对application对象的监听器接口 | 作用 |
---|---|
ServletContextListener |
用于对servletContext对象创建、销毁的监听 |
ServletContextAttributeListener |
用于对servletContext对象中属性增删改的监听 |
对session对象的监听器接口 | 作用 |
---|---|
HttpSessionListener |
用于对session对象创建、销毁的监听 |
HttpSessionAttributeListener |
用于对session对象中属性增删改的监听 |
HttpSessionBindingListener |
用于对session对象绑定、解绑的监听 |
HttpSessionActivationListener |
用于对session对象钝化、活化的监听 |
对request对象的监听器接口 | 作用 |
---|---|
ServletRequestListener |
用于对request对象创建、销毁的监听 |
ServletRequestAttributeListener |
用于对request对象中属性的增删改的监听 |
@WebListener
public class MyListener implements ServletContextListener {
...
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK