示例#1
0
  /**
   * Static version of {@link #initWebappDefaults(String)}
   *
   * @param ctx The context to set the defaults for
   */
  public static void initWebappDefaults(Context ctx) {
    // Default servlet
    Wrapper servlet = addServlet(ctx, "default", "org.apache.catalina.servlets.DefaultServlet");
    servlet.setLoadOnStartup(1);
    servlet.setOverridable(true);

    // JSP servlet (by class name - to avoid loading all deps)
    servlet = addServlet(ctx, "jsp", "org.apache.jasper.servlet.JspServlet");
    servlet.addInitParameter("fork", "false");
    servlet.setLoadOnStartup(3);
    servlet.setOverridable(true);

    // Servlet mappings
    ctx.addServletMapping("/", "default");
    ctx.addServletMapping("*.jsp", "jsp");
    ctx.addServletMapping("*.jspx", "jsp");

    // Sessions
    ctx.setSessionTimeout(30);

    // MIME mappings
    for (int i = 0; i < DEFAULT_MIME_MAPPINGS.length; ) {
      ctx.addMimeMapping(DEFAULT_MIME_MAPPINGS[i++], DEFAULT_MIME_MAPPINGS[i++]);
    }

    // Welcome files
    ctx.addWelcomeFile("index.html");
    ctx.addWelcomeFile("index.htm");
    ctx.addWelcomeFile("index.jsp");
  }
示例#2
0
 private void addDefaultServlet(Context context) {
   Wrapper defaultServlet = context.createWrapper();
   defaultServlet.setName("default");
   defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
   defaultServlet.addInitParameter("debug", "0");
   defaultServlet.addInitParameter("listings", "false");
   defaultServlet.setLoadOnStartup(1);
   // Otherwise the default location of a Spring DispatcherServlet cannot be set
   defaultServlet.setOverridable(true);
   context.addChild(defaultServlet);
   context.addServletMapping("/", "default");
 }