jee中的监听器
程序员文章站
2022-05-01 12:42:46
...
在web.xml是有一项
其中[color=darkred]org.iteye.bbjava.yourFuncListener[/color]就是你自已的监听器。
下面是[size=large]监听器的写法[/size]:
[quote]
ServletContextEvent :
This is the event class for notifications about changes to the servlet context of a web application. [/quote]
什么时候需要监听器?
<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]
什么时候需要监听器?