Example usage for javax.servlet ServletRegistration.Dynamic getInitParameter

List of usage examples for javax.servlet ServletRegistration.Dynamic getInitParameter

Introduction

In this page you can find the example usage for javax.servlet ServletRegistration.Dynamic getInitParameter.

Prototype

public String getInitParameter(String name);

Source Link

Document

Gets the value of the initialization parameter with the given name that will be used to initialize the Servlet or Filter represented by this Registration object.

Usage

From source file:net.ljcomputing.sr.config.StatusReporterWebConfiguration.java

/**
 * @see org.springframework.boot.context.web.SpringBootServletInitializer#onStartup(javax.servlet.ServletContext)
 *///from w  w w.  ja v  a  2 s  . c o m
public void onStartup(ServletContext container) throws ServletException {
    logger.info("onStartup ...");
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(StatusReporterWebConfiguration.class);
    ctx.setServletContext(container);

    DispatcherServlet ds = new DispatcherServlet(ctx);
    ServletRegistration.Dynamic servlet = container.addServlet("dispatcherServlet", ds);

    servlet.setInitParameter("throwExceptionIfNoHandlerFound", "true");
    servlet.setLoadOnStartup(1);
    servlet.addMapping("/");

    logger.warn("servlet name: {}", servlet.getName());
    logger.warn("servlet throwExceptionIfNoHandlerFound: {}",
            servlet.getInitParameter("throwExceptionIfNoHandlerFound"));
}