As with Spring 2.5, you can get a link to WebApplicationContext using the @Autowired annotation:
@Autowired WebApplicationContext applicationContext;
You can also get the ApplicationContext link by implementing the ApplicationContextAware interface:
public class YourController implements ApplicationContextAware { ApplicationContext applicationContext; public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } ... }
But I do not think that there is a way to get a link to an instance of DispatcherServlet or to an instance of any servlet present in your application. There used to be a way to get it using ServletContext.getServlet () , which is now deprecated.
source share