Example usage for org.springframework.web.servlet DispatcherServlet DispatcherServlet

List of usage examples for org.springframework.web.servlet DispatcherServlet DispatcherServlet

Introduction

In this page you can find the example usage for org.springframework.web.servlet DispatcherServlet DispatcherServlet.

Prototype

public DispatcherServlet(WebApplicationContext webApplicationContext) 

Source Link

Document

Create a new DispatcherServlet with the given web application context.

Usage

From source file:com.aalto.config.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    Logger.getLogger("config").log(Level.INFO, "log: Webinitializer onStartup method!!");
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);
    ctx.setServletContext(servletContext);
    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/*  w ww  .j  a v a2s  .  co m*/
}

From source file:edu.co.unbosque.software2.helloworld.config.WebInitializer.java

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

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Configuracion.class);
    ctx.setServletContext(servletContext);
    //        servletContext.addListener(new ContextLoaderListener(ctx));

    Dynamic servlet;/*  ww  w  .jav  a 2s  .  c  om*/
    servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);
}

From source file:org.fon.documentmanagementsystem.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);
    ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/* w ww .  ja v  a  2  s  .com*/
    servlet.setMultipartConfig(new MultipartConfigElement("", 1024 * 1024 * 25, 1024 * 1024 * 25, 0));

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);
    FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding",
            characterEncodingFilter);
    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
}

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);/* w  w w  .j av a  2s  .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);//ww w .j a va  2s.c om
    dispatcher.addMapping(MAPPING_URL);
}

From source file:com.example.m1.M1ServletConfig.java

public DispatcherServlet dispatcherServlet() {

    AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
    webContext.setParent(applicationContext);
    webContext.register(M1Config.class);
    //webContext.register(ThymeleafAutoConfiguration.class);
    webContext.scan("com.example.m1");

    DispatcherServlet dispatcherServlet = new DispatcherServlet(webContext);
    return dispatcherServlet;

}

From source file:gr.pskoufos.initializer.AppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);
    servletContext.addListener(new ContextLoaderListener(ctx));
    servletContext.addListener(new RequestContextListener());
    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);//ww w.jav a  2 s  .c  o m
}

From source file:org.bitcoinrt.spring.config.BitcoinServletInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext cxt = new AnnotationConfigWebApplicationContext();
    cxt.register(ServerConfig.class);

    DispatcherServlet servlet = new DispatcherServlet(cxt);
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("main", servlet);
    dispatcher.setLoadOnStartup(1);/*from w  w w . j a v a  2  s. com*/
    dispatcher.setAsyncSupported(true);
    dispatcher.addMapping("/");
}

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  .  jav a 2  s  .com
    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:com.azirar.requester.ws.config.WebAppInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();

    dispatcherServlet.register(AppConf.class);

    dispatcherServlet.setServletContext(servletContext);

    //        //Added filter dynamically
    javax.servlet.FilterRegistration.Dynamic corsFilter = servletContext.addFilter("corsFilter",
            CorsFilter.class);
    corsFilter.addMappingForUrlPatterns(null, true, "/*");

    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);//from  ww  w.j a  v a2s  . c  o m
}