List of usage examples for org.springframework.web.servlet DispatcherServlet DispatcherServlet
public DispatcherServlet(WebApplicationContext webApplicationContext)
From source file:com.jjcosare.calculator.config.WebInitializer.java
@Override public void onStartup(ServletContext container) throws ServletException { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(WebConfig.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 w w.j a v a 2 s. co m*/ dispatcher.addMapping("/"); }
From source file:ch.thp.proto.spring.time.web.config.ServletAppInitializer.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);/*from w w w .jav a2s .c o m*/ dispatcher.addMapping("/*"); }
From source file:com.gopivotal.cloudfoundry.test.ApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext(); webContext.register(ApplicationConfiguration.class); ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(webContext)); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.addMapping("/"); }
From source file:com.thebinaryidiot.springnoxml.WebAppInitializer.java
/** * Called by Servlet Container when application is initialized * * @param sc//from ww w. j a v a 2 s . co m * @throws ServletException */ @Override public void onStartup(final ServletContext sc) throws ServletException { // register spring web components AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(WebAppConfig.class); ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); }
From source file:net.eusashead.hateoas.springhalbuilder.config.WebInitializer.java
@Override public void onStartup(ServletContext ctx) throws ServletException { // Set up the app ctx AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext(); rootCtx.register(WebConfig.class); // Set the listener ctx.addListener(new ContextLoaderListener(rootCtx)); // Register the Spring Dispatcher servlet ServletRegistration.Dynamic dispatcher = ctx.addServlet("dispatcher", new DispatcherServlet(rootCtx)); dispatcher.setLoadOnStartup(1);// w ww . j a v a 2s . c om dispatcher.addMapping("/*"); }
From source file:org.beast.project.template.initializer.WebxmlConfig.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);//from w ww. j av a 2 s .c o m dispatcher.addMapping(MAPPING_URL); ServletRegistration.Dynamic ws = servletContext.addServlet("MessageDispatcherServlet", new MessageDispatcherServlet(context)); ws.setInitParameter("transformWsdlLocations", "true"); // Don't use this in production ws.addMapping("/services/*"); }
From source file:com.zbum.example.springweb.initializer.WebInitializer.java
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);//from w w w. j a v a 2 s.c om dispatcher.addMapping(MAPPING_URL); }
From source file:org.jblogcms.core.config.MainConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(MainContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);//from w w w . jav a 2 s . c o m dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy()); security.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); servletContext.addListener(new ContextLoaderListener(rootContext)); }
From source file:com.art4ul.jcoonsample.server.ServerLauncher.java
private static ServletContextHandler getServletContextHandler(WebApplicationContext context) throws IOException { ServletContextHandler contextHandler = new ServletContextHandler(); contextHandler.setErrorHandler(null); contextHandler.setContextPath(CONTEXT_PATH); contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), MAPPING_URL); contextHandler.addEventListener(new ContextLoaderListener(context)); return contextHandler; }
From source file:com.nkapps.billing.configs.WebAppInitializer.java
@Override public void onStartup(ServletContext container) { /*FilterRegistration.Dynamic encodingFilter = container.addFilter("encoding-filter", new CharacterEncodingFilter()); encodingFilter.setInitParameter("encoding", "UTF-8"); encodingFilter.setInitParameter("forceEncoding", "true"); encodingFilter.addMappingForUrlPatterns(null, true, "/*");*/ // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(HibernateConfig.class, ServiceConfig.class, RabbitMQConfig.class); // Manage the lifecycle of the root application context container.addListener(new ContextLoaderListener(rootContext)); // Create the dispatcher servlet's Spring application context AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext(); dispatcherServlet.register(MvcConfig.class); DispatcherServlet dp = new DispatcherServlet(dispatcherServlet); dp.setThrowExceptionIfNoHandlerFound(true); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", dp); dispatcher.setLoadOnStartup(1);// w ww.j av a 2 s .com dispatcher.addMapping("/"); }