jee中的监听器
在web.xml是有一项
<listener>
<listener-class>org.iteye.bbjava.YourFuncListener</listener-class>
</listener>
其中org.iteye.bbjava.yourFuncListener就是你自已的监听器。 下面是监听器的写法:
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
}
}
ServletContextEvent : This is the event class for notifications about changes to the servlet context of a web application.
什么时候需要监听器?