Example usage for javax.servlet ServletRegistration.Dynamic addMapping

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

Introduction

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

Prototype

public Set<String> addMapping(String... urlPatterns);

Source Link

Document

Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

Usage

From source file:echec.spring.SpringConfigWebApplicationInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    // Initialise spring au dmarrage de l'application web.
    AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
    appContext.register(SpringConfig.class);
    servletContext.addListener(new ContextLoaderListener(appContext));

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(appContext));
    dispatcher.setLoadOnStartup(1);//from   w w  w . j av  a2  s. c  om
    dispatcher.addMapping("/");
}

From source file:olsps.com.healthsoftproject.config.SpringWebAppInitializer.java

@Override
public void onStartup(ServletContext container) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ApplicationConfigClass.class);

    // Manage the lifecycle of the root application context
    container.addListener(new ContextLoaderListener(rootContext));
    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher",
            new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);/*from  w  w w . ja v  a 2s .  c  om*/
    dispatcher.addMapping("/");

}

From source file:com.navita.mavenproject4.config.WebInit.java

@Override
public void onStartup(ServletContext sc) throws ServletException {

    AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
    dispatcherServlet.register(MvcConfig.class);
    ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher",
            new DispatcherServlet(dispatcherServlet));

    dispatcher.setLoadOnStartup(1);/*from   ww w  .ja  v a2 s  . c  o m*/
    dispatcher.addMapping("/");

    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(JpaConfig.class);
    sc.addListener(new ContextLoaderListener(rootContext));

}

From source file:com.tamnd.app.init.WebMvcInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    // Create the 'root' Spring application context
    WebApplicationContext context = context();

    // Manage the lifecycle of the root application context
    servletContext.addListener(new ContextLoaderListener(context));

    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcherServlet", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);/*  w w w . j a va 2 s  . c  o  m*/
    dispatcher.addMapping(MAPPING_URL);

    servletContext
            .addFilter("securityFilter",
                    new DelegatingFilterProxy("springSecurityFilterChain"/*Do not change this name*/))
            .addMappingForUrlPatterns(null, false, "/*");
    //      servletContext.addFilter("hibernateFilter", new OpenSessionInViewFilter())
    //            .addMappingForUrlPatterns(null, false, "/*");
}

From source file:ca.unx.template.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    /* Let super do its thing... */
    super.onStartup(servletContext);

    /* Add the Spring Security filter. */
    servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy())
            .addMappingForUrlPatterns(null, false, "/*");

    // Add metrics servlet.
    ServletRegistration.Dynamic metricsServlet = servletContext.addServlet("metrics", AdminServlet.class);
    metricsServlet.addMapping("/metrics/*");
}

From source file:com.thebinaryidiot.springnoxml.WebAppInitializer.java

/**
 * Called by Servlet Container when application is initialized
 *
 * @param sc//w  ww  .j a v a2 s.  c o m
 * @throws ServletException
 */
@Override
public void onStartup(final ServletContext sc) throws ServletException {
    // register spring web components
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(WebAppConfig.class);
    ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher",
            new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
}

From source file:com.mycompany.spring2explore.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext cs) {

    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(SpringRootConfig.class);
    // Manage the lifecycle of the root application context
    cs.addListener(new ContextLoaderListener(rootContext));

    // Create the dispatcher servlet's Spring application context
    AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
    dispatcherServlet.register(MvcConfig.class);

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = cs.addServlet("dispatcher",
            new DispatcherServlet(dispatcherServlet));
    dispatcher.setLoadOnStartup(1);/*from  w  w  w  .  j a va  2 s.co  m*/
    dispatcher.addMapping("/");
}

From source file:org.emmanuel.spring.chat.config.webxml.WebXml.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);//from ww  w. j  av a 2  s .  c o m
    dispatcher.addMapping(MAPPING_URL);
}

From source file:com.github.mrstampy.gameboot.otp.websocket.WebSocketTestInitializer.java

@Override
public void onStartup(ServletContext container) throws ServletException {
    log.info("********************** YEP, ITS WORKING ******************");

    ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet());
    registration.setLoadOnStartup(1);//from www.j a  v  a 2 s .c  o  m
    registration.addMapping("/");
}

From source file:SpringWebAppInitializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(ApplicationContextConfig.class);
    ServletRegistration.Dynamic dispactherservlet = sc.addServlet("SpringDispacther",
            new DispatcherServlet(applicationContext));
    dispactherservlet.setLoadOnStartup(1);
    dispactherservlet.addMapping("/");

}