SpringWebApplicationInitializer.java 文件源码

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

项目:nbone 作者:
/**
* <p>默认关闭<p>
* 加载spring mvc 统一调度器
* @param servletContext
*/
  protected void initDispatcherServlet(ServletContext servletContext){
    String enable  = servletContext.getInitParameter("enableDispatcherServlet");
    if(BooleanUtils.valueOf(enable)){
        //classpath*:/spring-mvc*.xml,/WEB-INF/spring-mvc*.xml
        XmlWebApplicationContext appContext = new XmlWebApplicationContext();
        appContext.setConfigLocation("classpath*:/spring/spring-mvc*.xml,/WEB-INF/spring/spring-mvc*.xml");


        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(appContext));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");

    }

  }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号