方法一、

@Override
public void sessionDestroyed(HttpSessionEvent event) {

ServletContext context
= event.getSession().getServletContext();
ApplicationContext ctx
= WebApplicationContextUtils.getWebApplicationContext(context);
LoginTempService loginTempService
= (loginTempService)ctx.getBean("loginTempService");
}

方法二、如果在 web工程里,有几个方法,我觉得这个方法最方便。建个类,实现spring的ApplicationContextAware 接口,即 

public class SpringContextTool implements ApplicationContextAware {
private static ApplicationContext context;
public void setApplicationContext(ApplicationContext acx) {
context
= acx;
}

public static ApplicationContext getApplicationContext() {
return context;
}
}