Spring的DispatcherServlet如何获取getServletContext()?

时间:2018-10-13 12:52:32

标签: java spring

我目前正在学习Spring API。我发现DispatcherServlet从其超类getServletContext()继承了GenericServlet,如其docs所述。我还检查了DispatcherServlet extends FrameworkServlet包含reference to webApplicationContext的事实。 XmlWebApplicationContext的具体实现WebApplicationContext也从其超类getServletContext()继承AbstractRefreshableWebApplicationContext,如its API docs中所述。

尽管我知道调用DispatcherServlet.getServletContext()会调用GenericServlet.getServletContext(),但webApplicationContext.getServletContext()中可用的DispatcherServlet呢?它是否指向与GenericServlet.getServletContext()相同的对象并且是多余的?还是不同,还有其他用途?

0 个答案:

没有答案