Search in sources :

Example 1 with JspServletConfiguration

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

the class AbstractServletWebServer method addJspServlet.

/**
 * Add jsp to context
 */
protected void addJspServlet() {
    JspServletConfiguration jspServletConfiguration = this.jspServletConfiguration;
    if (jspServletConfiguration != null) {
        // config jsp servlet
        getWebApplicationConfiguration().configureJspServlet(jspServletConfiguration);
        if (jspServletConfiguration.isEnabled()) {
            try {
                Servlet jspServlet = BeanUtils.newInstance(jspServletConfiguration.getClassName());
                log.info("Jsp is enabled, use jsp servlet: [{}]", jspServlet.getServletInfo());
                WebServletInitializer<Servlet> initializer = new WebServletInitializer<>(jspServlet);
                initializer.setName(jspServletConfiguration.getName());
                initializer.setOrder(Ordered.HIGHEST_PRECEDENCE);
                initializer.addUrlMappings(jspServletConfiguration.getUrlMappings());
                initializer.setInitParameters(jspServletConfiguration.getInitParameters());
                getContextInitializers().add(initializer);
            } catch (ClassNotFoundException e) {
                throw new ConfigurationException("jsp servlet class not found", e);
            }
        }
    }
}
Also used : ConfigurationException(cn.taketoday.core.ConfigurationException) Servlet(jakarta.servlet.Servlet) JspServletConfiguration(cn.taketoday.web.framework.config.JspServletConfiguration) WebServletInitializer(cn.taketoday.web.servlet.initializer.WebServletInitializer)

Aggregations

ConfigurationException (cn.taketoday.core.ConfigurationException)1 JspServletConfiguration (cn.taketoday.web.framework.config.JspServletConfiguration)1 WebServletInitializer (cn.taketoday.web.servlet.initializer.WebServletInitializer)1 Servlet (jakarta.servlet.Servlet)1