List of usage examples for javax.servlet ServletRegistration.Dynamic addMapping
public Set<String> addMapping(String... urlPatterns);
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);// ww w .j a va 2 s . c om appServlet.addMapping("/"); }
From source file:com.nebhale.cyclinglibrary.web.ApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(UtilConfiguration.class, RepositoryConfiguration.class); servletContext.addListener(new ContextLoaderListener(rootContext)); AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext(); webContext.register(WebConfiguration.class); ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(webContext)); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.addMapping("/"); FilterRegistration.Dynamic gzipFilter = servletContext.addFilter("gzip", new GzipFilter()); gzipFilter.addMappingForServletNames(null, false, "dispatcher"); FilterRegistration.Dynamic eTagFilter = servletContext.addFilter("etag", new ShallowEtagHeaderFilter()); eTagFilter.addMappingForServletNames(null, false, "dispatcher"); }
From source file:org.uoiu.platform.web.DefaultWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); // appContext.register(AppConfig.class); appContext.getEnvironment().setActiveProfiles("webapp"); servletContext.addListener(new ContextLoaderListener(appContext)); AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext(); mvcContext.register(MvcConfig.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(mvcContext)); dispatcher.setLoadOnStartup(1);/*ww w . j av a 2 s . c o m*/ dispatcher.addMapping("/"); FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter", characterEncodingFilter()); encodingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); }
From source file:de.interseroh.report.webapp.UiWebAppInitializer.java
private void addMvcServlet(ServletContext servletContext) { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.register(WebMvcConfig.class); DispatcherServlet dispatcherServlet = new DispatcherServlet(context); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, dispatcherServlet);//w ww .j av a 2 s .co m dispatcher.setLoadOnStartup(1); dispatcher.addMapping(VIEWS_BASE); }
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);/* 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:com.coffeebeans.services.config.initializer.WebAppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppConfig.class); servletContext.addListener(new ContextLoaderListener(rootContext)); AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext(); dispatcherServlet.register(MvcConfig.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(MVC_DISPATCHER_NAME, new DispatcherServlet(dispatcherServlet)); dispatcher.setLoadOnStartup(1);/*ww w . j ava2s . c o m*/ dispatcher.addMapping("/1/*"); dispatcher.addMapping("/oauth/token"); FilterRegistration charEncodingFilterReg = servletContext.addFilter("CharacterEncodingFilter", CharacterEncodingFilter.class); charEncodingFilterReg.setInitParameter("encoding", "UTF-8"); charEncodingFilterReg.setInitParameter("forceEncoding", "true"); charEncodingFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); }
From source file:com.digitgroup.fullstackroad.spring.config.web.WebAppInitializer.java
@Override public void onStartup(ServletContext container) { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppRootConfig.class, PersistenceConfig.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(WebConfig.class); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet)); dispatcher.setLoadOnStartup(1);// ww w . ja v a 2s. c o m dispatcher.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 av a 2 s.c om dispatcher.addMapping("/"); }
From source file:eu.enhan.timelord.web.init.TimelordWebInit.java
/** * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext) */// www . j a va2s. co m @Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext(); rootCtx.register(AppConfig.class); servletContext.addListener(new ContextLoaderListener(rootCtx)); AnnotationConfigWebApplicationContext webAppCtx = new AnnotationConfigWebApplicationContext(); webAppCtx.setParent(rootCtx); webAppCtx.register(WebConfig.class); XmlWebApplicationContext securityCtx = new XmlWebApplicationContext(); securityCtx.setServletContext(servletContext); securityCtx.setParent(rootCtx); securityCtx.setConfigLocation("classpath:/spring/security.xml"); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(webAppCtx)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); FilterRegistration.Dynamic securityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain", securityCtx)); // securityFilter.addMappingForUrlPatterns(null, false, "/**"); securityFilter.addMappingForServletNames(null, false, "dispatcher"); }
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);// w ww . j ava 2s . co 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)); }