Java基础 Servlet监听器详解

网友投稿 216 2023-05-03


Java基础 Servlet监听器详解

java基础 Servlet监听器详解

1 概念:Servlet监听器,用来监听web容器的一些对象状态的变化,主要是ServletContext、HttpSession、HttpServletRequestl三类对象状态。Servlet的监听器

2  Servlet2.4和jsP2.0规范中一共定义了有八个接口类和六种事件。

3 web.xml中定义Servlet的url-pattern时如果url-pattern的值的"/",则说明该Servlet是该项目的默认Servlet,当请求路径匹配不到

具体的某个Servlet的时候,由该Servlet来处理该请求。为项目添加SpringMVC的应用就是将spring的DispatcherServlet作为默认的

Sehttp://rvlet,管理项目的请求。

这点与Filter的url-pattern的含义不一样。



接口类

功能描述

事件类

ServletContextListener                                                

监听ServletContext对象初始化和                                                                          

ServletContextEvent                                         

ServletContextAttributeListener

监听ServletContext对像属性的增加和移除事件

ServletContextAttributeEvent

HttpSessionListener

监听session创建和销毁

HttpSessionEvent

HttpSessionActivationListener

HttpSessionEvent

HttpSessionAttributeListener

监听session属性增减变化

HttpSessionBingEvent

HttpSessionBingListener

监听session对象绑定事件

HttpSessionBingEvent

ServletRequestListener

监听request对象

HttpRequestEvent

ServletRequestAttributeListener

监听request的属性的增减变化

HttpRequestAttributeEvent

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:React利用插件和不用插件实现双向绑定的方法详解
下一篇:CentOS 7快速安装jdk
相关文章

 发表评论

暂时没有评论,来抢沙发吧~