tomcat启动自动执行代码
可以添加Tomcat的 listener
在web.xml中添加listener节点
- <listener>
- <listener-class>com.PreloadListener</listener-class>
- </listener>
java代码:
- public class PreloadListener implements ServletContextListener{
- public void contextInitialized (ServeltContextEvent sce){
- //init operation 在此填写自己要加的代码程序main方法的内容
- }
- public void contextDestoryed (ServeltContextEvent sce){
- //destory operation
- }
- }
浙公网安备 33010602011771号