欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jee中的监听器

程序员文章站 2022-05-01 12:42:46
...
在web.xml是有一项
<listener>
<listener-class>org.iteye.bbjava.YourFuncListener</listener-class>
</listener>


其中[color=darkred]org.iteye.bbjava.yourFuncListener[/color]就是你自已的监听器。
下面是[size=large]监听器的写法[/size]:

public class YourFuncListener implements ServletContextListener {

private static final long serialVersionUID = -2153378435692476097L;
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub

}
public void contextInitialized(ServletContextEvent event) {
// TODO Auto-generated method stub
}
}


[quote]
ServletContextEvent :
This is the event class for notifications about changes to the servlet context of a web application. [/quote]

什么时候需要监听器?
相关标签: listener