コード例 #1
0
  private WebAppContext buildWebAppContext(String[] args, Enviroment env) {

    AnnotationConfigWebApplicationContext applicationContext =
        new AnnotationConfigWebApplicationContext();
    applicationContext.register(WebContext.class);

    WebAppContext handler = new WebAppContext();
    handler.setContextPath(CONTEXT_NAME);
    handler.setDisplayName(DISPLAY_NAME);

    String[] resources = null;
    resources = new String[] {"./WebContent"};

    handler.setWelcomeFiles(new String[] {"index.html"});
    handler.setInitParameter("useFileMappedBuffer", "false");
    handler.setBaseResource(new ResourceCollection(resources));
    handler.setResourceAlias("/WEB-INF/classes/", "/classes/");

    this.appendListeners(applicationContext, handler);
    this.appendSpringDispatcherServlet(applicationContext, handler);

    applicationContext.close();
    return handler;
  }