Search in sources :

Example 1 with DefaultServletConfiguration

use of cn.taketoday.web.framework.config.DefaultServletConfiguration in project today-framework by TAKETODAY.

the class AbstractServletWebServer method addDefaultServlet.

/**
 * Add default servlet
 */
protected void addDefaultServlet() {
    DefaultServletConfiguration servletConfiguration = this.defaultServletConfiguration;
    if (servletConfiguration != null) {
        // config default servlet
        getWebApplicationConfiguration().configureDefaultServlet(servletConfiguration);
        if (servletConfiguration.isEnable()) {
            Servlet defaultServlet = getDefaultServlet(servletConfiguration);
            if (defaultServlet != null) {
                log.info("Default servlet is enabled, use servlet: [{}]", defaultServlet.getServletInfo());
                WebServletInitializer<Servlet> initializer = new WebServletInitializer<>(defaultServlet);
                initializer.setName(Constant.DEFAULT);
                initializer.setOrder(Ordered.HIGHEST_PRECEDENCE);
                initializer.addUrlMappings(servletConfiguration.getUrlMappings());
                initializer.setInitParameters(servletConfiguration.getInitParameters());
                getContextInitializers().add(initializer);
            }
        }
    }
}
Also used : DefaultServletConfiguration(cn.taketoday.web.framework.config.DefaultServletConfiguration) Servlet(jakarta.servlet.Servlet) WebServletInitializer(cn.taketoday.web.servlet.initializer.WebServletInitializer)

Aggregations

DefaultServletConfiguration (cn.taketoday.web.framework.config.DefaultServletConfiguration)1 WebServletInitializer (cn.taketoday.web.servlet.initializer.WebServletInitializer)1 Servlet (jakarta.servlet.Servlet)1