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

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

Introduction

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

Prototype

public void setContextClass(Class<?> contextClass) 

Source Link

Document

Set a custom context class.

Usage

From source file:com.github.mjeanroy.junit.servers.samples.jetty.java.configuration.WebApplicationConfiguration.java

private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) {
    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setContextConfigLocation(configLocation());
    dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);

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

From source file:com.mjeanroy.backbone_isomorphic.configuration.WebConfiguration.java

private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) {
    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setContextConfigLocation(configLocation());
    dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);//from  w w  w . ja v  a2  s .  c om
    dispatcher.addMapping("/api/*");
    dispatcher.addMapping("/");
}