八种监听器

1.监听器用来监听web程序中的事件,例如创建、修改、删除session、request、context等。

想要实现监听器的功能需要实现监听器的接口xxxLinetener,当Tomcat触发监听器的时候,会自动调用。

监听器可以分为四种类型:

监听对象的创建:

   ServletContext:主要监听servletContext的创建,需要实现ServeltContextListener接口。

   ServletRequest:主要监听request的创建, 需要实现ServletRequestListener接口

   HttpSession:主要监听session的创建,需要实现HttpSessionListener接口


监听属性的改变:

   ServletContext:主要监听servletContext属性的更改、添加、删除,需要实现ServeltContextAttrbuteListener接口。

   ServletRequest:主要监听request属性的更改、添加、删除, 需要实现ServletRequestAttrbuteListener接口

   HttpSession:主要监听session属性的更改、添加、删除,需要实现HttpSessionAttrbuteListener接口


监听session的活化与钝化:

httpSessionActivationListener主要监听了session的活化与钝化

监听session与对象的绑定:

httpSessionBindingListener监听了session与对象的绑定

猜你喜欢

转载自blog.csdn.net/csdn19970806/article/details/80707271