1.监听器
开发步骤:
a.编写监听器,实现接口
b.配置web.xml
监听对象:request session application三个对象
a.监听对象的创建和销毁
request:ServletRequestListener
session:HttpSessionListener
application:ServletContextListener
每个监听器提供两个方法:监听开始,监听结束的方法。
ServletContext在servlet容器创建时 自动创建
b.监听对象中属性的变更
request:ServletRequestAttributeListener
session:HttpSessionAttributeListener
application:ServletContextAttributeListener
2.session的钝化和活化
钝化:内存->硬盘
活化:硬盘->活化
session对象的四种状态:
监听session对象的绑定和解绑:HttpSessionBindingListener
a. session.setAttribute(); 对象a【绑定】到session中
b. session.removeAttribute(); 将对象a从session中【解绑】
监听session对象的钝化、活化:HttpSessionActivationListener
c. 钝化
d. 活化
监听器和Ajax学习
最新推荐文章于 2024-12-07 22:55:08 发布