可以用批处理,
也可以继承ServletContextAttributeListener,ServletContextListener 类。
在服务器退出时执行删除,继承这两个类主要要实现以下两个方法:
public void contextInitialized(ServletContextEvent event) //tomcat启动时
public void contextDestroyed(ServletContextEvent event) //tomcat关闭时
下面这三个方法可以不实现:
public void attributeReplaced(ServletContextAttributeEvent event)
public void attributeRemoved(ServletContextAttributeEvent event)
public void attributeAdded(ServletContextAttributeEvent event)