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.contact.MyWebAppInitializer.java

public void onStartup(ServletContext container) throws ServletException {
    XmlWebApplicationContext appContext = new XmlWebApplicationContext();

    appContext.setConfigLocation("/WEB-INF/spring/appServlet/servlet-context.xml");

    ServletRegistration.Dynamic dispatcher = container.addServlet("appServlet",
            new DispatcherServlet(appContext));

    MultipartConfigElement multipartConfigElement = new MultipartConfigElement(null, 5000000, 5000000, 0);
    dispatcher.setMultipartConfig(multipartConfigElement);

    dispatcher.setLoadOnStartup(1);//from www . java 2 s.c  om
    dispatcher.addMapping("/");
}

From source file:com.bitran.config.Inicializador.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.bitran");
    sc.addListener(new ContextLoaderListener(ctx));
    Dynamic servlet = sc.addServlet("appServlet", new DispatcherServlet(ctx));
    servlet.setAsyncSupported(true);//from ww  w  .  j  a  v a2s .  com
    servlet.setLoadOnStartup(1);
    servlet.addMapping("*.action");
}

From source file:id.ac.ipb.ilkom.training.ApplicationInitializer.java

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

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfiguration.class);
    ctx.setServletContext(container);/*from   w  w  w.ja v a 2 s .c o m*/

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

    servlet.setLoadOnStartup(1);
    servlet.addMapping("/");
}

From source file:ui.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfig.class);
    ctx.setServletContext(sc);// w  w w.j  av a2 s .  c om

    Dynamic dynamic = sc.addServlet("UserController", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);
}

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);//ww w.  j a  v  a  2  s .com
    dispatcher.addMapping("/");

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

}

From source file:de.asgarbayli.rashad.hbd.config.WebInitializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(Config.class);
    context.setServletContext(sc);//from  w  w w .j ava 2 s .c om
    Dynamic servlet = sc.addServlet("dispatcher", new DispatcherServlet(context));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);
}

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("/");

}

From source file:com.library.bookarticlelibrary.WebAppInitializer.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);//  w  w w . j a  v  a 2  s  .c om
    dispatcher.addMapping("/");
    dispatcher.addMapping("*.css");
    dispatcher.addMapping("*.js");
    dispatcher.addMapping("*.pdf");
    dispatcher.addMapping("*.json");
}

From source file:com.opencart.config.Initializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(SpringConfigurations.class);
    sc.addListener(new ContextLoaderListener(ctx));

    ctx.setServletContext(sc);/*from   w  w  w.j  a v a 2  s . c  o  m*/

    Dynamic servlet = sc.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);

}

From source file:rashjz.info.com.az.config.MyWebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
    appContext.register(SpringWebConfig.class);

    DispatcherServlet dispatcherServlet = new DispatcherServlet(appContext);
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("SpringDispatcher", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);//from  ww  w  . j  a va 2  s .c o m
    dispatcher.addMapping("/");

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
    FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding",
            characterEncodingFilter);
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
}