首页 > 编程 > Java > 正文

Java基础 Servlet监听器详解

2019-11-26 11:56:02
字体:
来源:转载
供稿:网友

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作为默认的

Servlet,管理项目的请求。

         这点与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

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表