Java web Listener Listener

Listener: Listener

Concept: One of the three major components of web

  • Event listener mechanism

    • Event: One thing
    • Event Source: Local events
    • Listener: An object
    • Register listeners: event, event source, listeners are bound together. When an event occurs on the event source, listeners execute code.
  • ServletContextListener: create and destroy objects listening Servletconte

    • void contextDestroy (ServletContextEvent sce): calls before being destroyed
    • void contextInitialized (ServletContextEvent sce): After the object is created will be called
  • step

    • Defining class implements interfaces ServletContextListener

    • Replication method

    • Configuration

      • web.xml

        • <listener></listener>
          
      • annotation

        • @WebListener
Published 70 original articles · won praise 43 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_25884515/article/details/103993938