监听web的启动和关闭

public class TomcatListen implements ServletContextListener{
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		
		System.out.println("Tomcat服务器启动,现在时间为:"+tomcatStartTime);
	}
	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
	
		System.out.println("Tomcat服务器关闭");
	}

}

web.xml添加


        com.test.TestListener

 

你可能感兴趣的:(java)