ContextLoader.getCurrentWebApplicationContext().getServletContext()
web.xml里加个:
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>