上下文监听

package com.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
* 上下文监听
*
*/
public class ServletContextListenerDemo implements ServletContextListener {

public void contextDestroyed(ServletContextEvent event) {
//上下文销毁时出发
System.out.println("** 容器销毁-->" + event.getServletContext().getContextPath());
}

public void contextInitialized(ServletContextEvent event) {
//上下文初始化时出发
System.out.println("** 容器初始化-->" + event.getServletContext().getContextPath());
}

}

 

web.xml

<listener>
<listener-class>com.listener.ServletContextListenerDemo</listener-class>
</listener>

posted @ 2013-04-16 11:00  幻星宇  阅读(136)  评论(0编辑  收藏  举报