1)通過session獲取spring上下文:
ServletContext context = request.getSession().getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
yourService = (YourService)ctx.getBean("yourService");