监听器以及在监听类里面获得bean的方法

1实现HttpSessionListener和ServletContextListener,2个接口

2然后在contextInitialized初始化方法里面:

        ServletContext application = event.getServletContext();  
        WebApplicationContext appctx = WebApplicationContextUtils.getWebApplicationContext(application);  
        newsSubmissionService = appctx.getBean(NewsSubmissionService.class);

3在web.xml里面配置监听器以及在监听类里面获得bean的方法

<listener>  
        <listener-class>com.guduo.log.TaskReBack</listener-class>  
</listener>

 

相关文章:

  • 2022-12-23
  • 2021-10-06
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-02
  • 2021-08-21
  • 2022-01-10
  • 2021-10-30
  • 2022-12-23
相关资源
相似解决方案