List of usage examples for org.springframework.web.servlet DispatcherServlet DispatcherServlet
public DispatcherServlet(WebApplicationContext webApplicationContext)
From source file:org.jboss.arquillian.spring.testsuite.beans.web.EmployeeWebRootInitializer.java
/** * {@inheritDoc}//from www .j a v a2 s . c o m */ public void onStartup(ServletContext servletContext) throws ServletException { // creates the web root app context AnnotationConfigWebApplicationContext webRootContext = new AnnotationConfigWebApplicationContext(); webRootContext.register(WebAppConfig.class); // registers context load listener servletContext.addListener(new ContextLoaderListener(webRootContext)); // adds a dispatch servlet, the servlet will be configured from root web app context ServletRegistration.Dynamic servletConfig = servletContext.addServlet("employee", new DispatcherServlet(new AnnotationConfigWebApplicationContext())); servletConfig.setLoadOnStartup(1); servletConfig.addMapping("*.htm"); }
From source file:com.miko.s4netty.config.WorkerWebInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(WorkerWebConfig.class); logger.debug("WebInitializer onStartup"); ctx.setConfigLocation("spring/app-worker-config.xml"); ctx.setServletContext(servletContext); Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1);/*from w w w. j av a2 s . c o m*/ }
From source file:ch.javaee.basicMvc.WebInitializer.java
@Override public void onStartup(ServletContext container) throws ServletException { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppConfiguration.class); // Manage the lifecycle of the root application context container.addListener(new ContextLoaderListener(rootContext)); // Create the dispatcher servlet's Spring application context AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(DispatcherConfig.class); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1);//w ww .j a v a2 s .c o m dispatcher.addMapping("/"); }
From source file:org.homiefund.init.WebAppBoostrapper.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationConfiguration.class, SecurityConfiguration.class); servletContext.addListener(new ContextLoaderListener(rootContext)); servletContext.addListener(new RequestContextListener()); AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(MvcConfiguration.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1);// w w w .j ava 2 s.c o m dispatcher.setAsyncSupported(true); dispatcher.addMapping("/"); servletContext.addFilter("encodingFilter", new CharacterEncodingFilter("UTF-8", true)) .addMappingForUrlPatterns(null, false, "/*"); servletContext.addFilter("httpMethodFilter", new HiddenHttpMethodFilter()).addMappingForUrlPatterns(null, true, "/*"); }
From source file:com.lyncode.jtwig.acceptance.AbstractJtwigAcceptanceTest.java
private void startServer() throws Exception { jetty = new Server(0); final AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); applicationContext.register(ConfigClass.class, getClass()); applicationContext.register(configurationClasses()); final ServletHolder servletHolder = new ServletHolder(new DispatcherServlet(applicationContext)); final ServletContextHandler context = new ServletContextHandler(); context.setErrorHandler(null); // use Spring exception handler(s) context.setContextPath("/"); context.setBaseResource(Resource.newResource(new ClassPathResource("").getURI().toString())); context.setSessionHandler(new SessionHandler()); context.addServlet(servletHolder, "/"); jetty.setHandler(context);/* w w w.j a v a 2s. c o m*/ jetty.start(); }
From source file:org.jbr.commons.container.http.StandardWebAppInitializer.java
protected void createDispatcherServlet(final ServletContext servletContext, final WebApplicationContext rootContext) { final ServletRegistration.Dynamic appServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext)); appServlet.setLoadOnStartup(1);/* w ww . j a v a 2s .c om*/ appServlet.addMapping("/"); }
From source file:org.avidj.zuul.rs.ZuulInitializer.java
@Override public void onStartup(ServletContext container) { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(RootContextConfiguration.class); // Manage the lifecycle of the root application context container.addListener(new ContextLoaderListener(rootContext)); // Create the dispatcher servlet's Spring application context AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(MvcContextConfiguration.class); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1);/*from w w w .j a v a 2 s. c om*/ dispatcher.addMapping("/"); }
From source file:fi.m1kah.web.WebAppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppConfig.class); servletContext.addListener(new ContextLoaderListener(rootContext)); AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(DispatcherConfig.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1);// ww w .j a v a 2s .c o m dispatcher.addMapping("/api/*"); }
From source file:br.eti.danielcamargo.backend.common.config.WebAppInitializer.java
private void configureWebServlets(ServletContext servletContext, WebApplicationContext rootContext) { AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext(); mvcContext.register(WebConfig.class); mvcContext.setParent(rootContext);/*from w w w . jav a2 s.c o m*/ DispatcherServlet restDispatcherServlet = new DispatcherServlet(mvcContext); String restDispatcherName = "Rest Servlet"; ServletRegistration.Dynamic restServletRegistration = servletContext.addServlet(restDispatcherName, restDispatcherServlet); restServletRegistration.setLoadOnStartup(1); restServletRegistration.addMapping("/rest/*"); }
From source file:org.ratty.configs.AppConfig.java
public void onStartup(ServletContext servletContext) throws ServletException { final AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(AppConfig.class); ctx.setServletContext(servletContext); final ServletRegistration.Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); dynamic.addMapping("/"); dynamic.setLoadOnStartup(1);/* w w w. j a v a2 s . c o m*/ }