List of usage examples for javax.servlet FilterRegistration addMappingForServletNames
public void addMappingForServletNames(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, String... servletNames);
From source file:com.test.config.BackendConsoleWebConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext(); webCtx.register(BackendConsoleMVCConfig.class); webCtx.register(BackendConsoleConfig.class); servletContext.addListener(new ContextLoaderListener(webCtx)); /* Spring Delegating Dispatcher Servlet */ Servlet dispatcherServlet = new DispatcherServlet(webCtx); ServletRegistration.Dynamic dispatcherServletReg = servletContext.addServlet("dispatcherServlet", dispatcherServlet);/* www . j av a 2 s . com*/ dispatcherServletReg.setLoadOnStartup(1); dispatcherServletReg.setInitParameter("contextConfigLocation", ""); dispatcherServletReg.addMapping("/"); /* Spring Security Delegating Filter */ FilterRegistration springSecurityFilterChainReg = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class); springSecurityFilterChainReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.ASYNC), false, dispatcherServletReg.getName()); }
From source file:org.kuali.coeus.sys.framework.config.KcConfigurer.java
@Override protected void doAdditionalModuleStartLogic() throws Exception { if (StringUtils.isNotBlank(dispatchServletName)) { DispatcherServlet loaderServlet = new DispatcherServlet( (WebApplicationContext) ((SpringResourceLoader) rootResourceLoader.getResourceLoaders().get(0)) .getContext());//from www.ja v a2 s . c o m ServletRegistration registration = getServletContext().addServlet(dispatchServletName, loaderServlet); registration.addMapping("/" + dispatchServletName + "/*"); for (String filterName : filtersToMap) { FilterRegistration filter = getServletContext().getFilterRegistration(filterName); filter.addMappingForServletNames(null, true, dispatchServletName); } if (enableSpringSecurity) { DelegatingFilterProxy filterProxy = new DelegatingFilterProxy(SPRING_SECURITY_FILTER_CHAIN, (WebApplicationContext) ((SpringResourceLoader) rootResourceLoader.getResourceLoaders() .get(0)).getContext()); FilterRegistration.Dynamic securityFilter = getServletContext() .addFilter(KC_PREFIX + getModuleName() + SPRING_SECURITY_FILTER_PROXY, filterProxy); securityFilter.addMappingForServletNames(null, true, dispatchServletName); } } }