关于Listener调用Spring管理Bean问题
public class SessionListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {
private UserLogService userLogService;
private ServletContext servletContext;
@Override
public void contextInitialized(ServletContextEvent sce) {
this.servletContext = sce.getServletContext();
}
/**
* 设置服务类
*/
private void settingService() {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
this.userLogService = (UserLogService) wac.getBean("userLogService");
}
调用-》
if(this.userLogService == null){
this.settingService();
}