//从spring容易中获取bean public static Object getBean(String beanName){ ApplicationContext context = ContextLoader.getCurrentWebApplicationContext(); return context.getBean(beanName); } //获取ServletContext public static ServletContext getServletContext(){ WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext(); return context.getServletContext(); }