启动Tomcat的时候方法启动 ,可以使用监听。
1.继承ServletContextListener ,实现 contextInitialized(),contextDestroyed(),两个方法 。(第一个是要执行的方法,第二个监听器销毁)
2.配置web.xml监听(谨记)
3.测试结果
启动Tomcat的时候方法启动 ,可以使用监听。
1.继承ServletContextListener ,实现 contextInitialized(),contextDestroyed(),两个方法 。(第一个是要执行的方法,第二个监听器销毁)
2.配置web.xml监听(谨记)
3.测试结果