一、ServletContextListener 

Method Summary

 void

contextDestroyed(ServletContextEvent sce)
          Receives notification that the ServletContext is about to be shut down.

 void

contextInitialized(ServletContextEvent sce)
          Receives notification that the web application initialization process is starting.

代码举例:

package com.kdyzm.listener;

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

public class MyServletContextListener implements ServletContextListener{

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        ServletContext sc=sce.getServletContext();
        System.out.println(sc+"被销毁!");
    }

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println(sce.getServletContext()+"初始化!");
    }
    
}
ServletContextListener举例

相关文章:

  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2021-11-23
  • 2021-05-15
猜你喜欢
  • 2021-08-11
  • 2022-12-23
  • 2022-02-07
  • 2022-03-06
  • 2021-08-30
  • 2021-12-02
相关资源
相似解决方案