使用spring的工具类获得容器中的bean对象
public static IMail getMail(HttpServletRequest request)throws Exception{
ServletContext sc = request.getSession().getServletContext();
ApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
IMail mail = (IMail) ac.getBean("emailImpl");
return mail;
}