List of usage examples for org.springframework.web.servlet DispatcherServlet setApplicationContext
@Override public void setApplicationContext(ApplicationContext applicationContext)
From source file:com.cfitzarl.cfjwed.Main.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Add spring security filter chain servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class) .addMappingForUrlPatterns(null, false, "/*"); // Add Hibernate session binder servletContext.addFilter("jpaTransactionFilter", OpenEntityManagerInViewFilter.class) .addMappingForUrlPatterns(null, false, "/*"); // Define application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(WebApplicationMvcConfigurer.class); rootContext.scan("com.cfitzarl.cfjwed"); // Create a dispatcher servlet that loads the application context DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setApplicationContext(rootContext); // Add the dispatcher servlet to the servlet context and map it to / ServletRegistration.Dynamic servletRegister = servletContext.addServlet("dispatcher", dispatcherServlet); servletRegister.setLoadOnStartup(1); servletRegister.addMapping("/"); servletContext.addListener(new ContextLoaderListener(rootContext)); }