DispatcherServletInitializer.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:communote-server 作者:
private void createMainDispatcherServlet(ApplicationContext rootContext) {
    mainWebApplicationContext = new XmlWebApplicationContext();
    mainWebApplicationContext
            .setConfigLocation(getRequiredInitParameter("communoteWebContextConfigLocation"));
    mainWebApplicationContext.setParent(rootContext);
    // add ContextLoaderListener with web-ApplicationContext which publishes it under a
    // ServletContext attribute and closes it on shutdown. The former is required for
    // WebApplicationContextUtils which are used by DelegatingFilterProxy (spring security).
    // Closing is also done by dispatcher servlet's implementation of destroy method.
    this.servletContext.addListener(new ContextLoaderListener(mainWebApplicationContext));
    DispatcherServlet dispatcherServlet = new DispatcherServlet(mainWebApplicationContext);
    ServletRegistration.Dynamic addedServlet = this.servletContext.addServlet(
            getInitParameter("communoteServletName", "communote"), dispatcherServlet);
    addedServlet.setLoadOnStartup(1);
    addedServlet.addMapping(getRequiredInitParameter("communoteServletUrlPattern"));
    this.mainDispatcherServlet = dispatcherServlet;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号