本文整理汇总了Java中javax.servlet.FilterRegistration.Dynamic.addMappingForUrlPatterns方法的典型用法代码示例。如果您正苦于以下问题:Java Dynamic.addMappingForUrlPatterns方法的具体用法?Java Dynamic.addMappingForUrlPatterns怎么用?Java Dynamic.addMappingForUrlPatterns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.FilterRegistration.Dynamic
的用法示例。
在下文中一共展示了Dynamic.addMappingForUrlPatterns方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartup
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
Dynamic fr = servletContext.addFilter("org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0", EmptyFilter.class);
if(fr!=null){
fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/fuckSpringBootFilterSecurityInterceptor");
fr.setAsyncSupported(true);
}
fr = servletContext.addFilter("org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0", EmptyFilter.class);
if(fr!=null){
fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/fuckSpringBootFilterSecurityInterceptor");
fr.setAsyncSupported(true);
}
fr = servletContext.addFilter("casFilter", EmptyFilter.class);
if(fr!=null){
fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/fuckSpringBootFilterSecurityInterceptor");
fr.setAsyncSupported(true);
}
}
示例2: run
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void run(BlogConfiguration blogConfiguration, Environment environment) throws Exception {
final BlogDao blogDao = new BlogDao(hibernate.getSessionFactory());
// Register all resources here.
environment.jersey().register(new BlogResources(blogDao));
environment.jersey().register(new UploadResources());
environment.jersey().register(new UnitTestResources());
// Register MultiPartFeature.class to support mime type "multipart/form-data."
environment.jersey().getResourceConfig().register(MultiPartFeature.class);
// All Filter
// CORS enable
Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
filter.setInitParameter("allowedHeaders", "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
filter.setInitParameter("allowCredentials", "true");
}
示例3: onStartup
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
webAppContext.setConfigLocation(getClass().getPackage().getName());
ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(webAppContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
OpenEntityManagerInViewFilter openEntityManagerInViewFilter = new OpenEntityManagerInViewFilter();
openEntityManagerInViewFilter.setEntityManagerFactoryBeanName("entityManagerFactory");
Dynamic dynamic = servletContext.addFilter("openEntityManagerInViewFilter", openEntityManagerInViewFilter);
dynamic.addMappingForUrlPatterns(getDispatcherTypes(), false, DISPATCHER_SERVLET_MAPPING);
servletContext.addListener(new ContextLoaderListener(webAppContext));
}
示例4: onStartup
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
configureSessionCookie(servletContext);
CharacterEncodingFilter cef = new CharacterEncodingFilter();
cef.setEncoding("UTF-8");
cef.setForceEncoding(true);
Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", cef);
characterEncodingFilter.setAsyncSupported(true);
characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");
//force log initialization, then disable it
XRLog.setLevel(XRLog.EXCEPTION, Level.WARNING);
XRLog.setLoggingEnabled(false);
}
示例5: setupContext
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
/**
* Sets up servlet context - registers {@link SessionFilter} and
* {@link ShutdownListener}.
*
* @param context
* servlet context to set up
*/
static void setupContext(ServletContext context) {
if (ServletLevel.isServlet3) {
// When using Servlet 3.x+, we will register SessionFilter to make
// sure session replacement is enabled
Dynamic reg = context.addFilter("com.amdeus.session.filter", new SessionFilter());
if (reg != null) {
// The filter applies to all requests
reg.addMappingForUrlPatterns(null, false, "/*");
}
// At the web app shutdown, we need to do some cleanup
context.addListener(new ShutdownListener());
}
}
示例6: contextInitialized
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
Dynamic filterRegistration = sce.getServletContext().addFilter("BraveServletFilter",
new BraveServletFilter(brave.serverRequestInterceptor(), brave.serverResponseInterceptor(), new DefaultSpanNameProvider()));
// Explicit mapping to avoid trace on readiness probe
filterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/api/hello", "/api/hello-chaining");
}
示例7: addExplicitlyDeclaredFilters
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
private void addExplicitlyDeclaredFilters(ServletContext webappContext) {
for (FilterData filterData : filterData) {
Dynamic filterReg = webappContext.addFilter(
filterData.getFilterName(), filterData.getFilter());
filterReg.addMappingForUrlPatterns(
EnumSet.allOf(DispatcherType.class),true,
filterData.getMapping());
logFilter(filterData);
}
}
示例8: setServletContext
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void setServletContext(ServletContext servletContext) {
try {
ServletRegistration openmrsServletReg = servletContext.getServletRegistration("openmrs");
addMappings(openmrsServletReg, "*.htm", "*.form", "*.list", "*.json", "*.field", "*.portlet", "*.page", "*.action");
addMappings(servletContext.getServletRegistration("jsp"), "*.withjstl");
ServletRegistration servletReg = servletContext.addServlet("logoutServlet", new LogoutServlet());
servletReg.addMapping("/logout");
Dynamic filter = servletContext.addFilter("forcePasswordChangeFilter", new ForcePasswordChangeFilter());
filter.setInitParameter("changePasswordForm", "/admin/users/changePassword.form");
filter.setInitParameter("excludeURL", "changePasswordForm,logout,.js,.css,.gif,.jpg,.jpeg,.png");
filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
filter = servletContext.addFilter("adminPageFilter", new AdminPageFilter());
filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/admin");
servletContext.addListener(new SessionListener());
/*
* EfficientShutdownServletContextAttributeListener is used instead of
* EfficientShutdownServletContextListener since the latter implements ServletContextListener,
* which is not supported by ServletContext.addListener.
*/
servletContext.addListener(new EfficientShutdownServletContextAttributeListener());
}
catch (Exception ex) {
//TODO need a work around for: java.lang.IllegalStateException: Started
//Unable to configure mapping for servlet because this servlet context has already been initialized.
//This happens on running openmrs after InitializationFilter or UpdateFilter
//hence requiring a restart to see any page other than index.htm
//After a restart, all mappings will then happen within Listener.contextInitialized()
ex.printStackTrace();
}
}
示例9: configureCors
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
private void configureCors(Environment environment) {
Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
filter.setInitParameter("allowedHeaders", "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
filter.setInitParameter("allowCredentials", "true");
}
示例10: contextInitialized
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext ctx = sce.getServletContext();
Dynamic filter = ctx.addFilter("JUGFilter", JugFilterDispatcher.class);
filter.setInitParameter("javax.ws.rs.Application", ApplicationConfig.class.getName());
filter.addMappingForUrlPatterns(EnumSet.of(REQUEST), true, "/*");
}
示例11: registerFilter
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
/**
* Registers the provided filter using the {@link #isAsyncSessionSupported()} and
* {@link #getSessionDispatcherTypes()}.
*
* @param servletContext the servlet context
* @param insertBeforeOtherFilters should this Filter be inserted before or after
* other {@link Filter}
* @param filterName the filter name
* @param filter the filter
*/
private void registerFilter(ServletContext servletContext,
boolean insertBeforeOtherFilters, String filterName, Filter filter) {
Dynamic registration = servletContext.addFilter(filterName, filter);
if (registration == null) {
throw new IllegalStateException(
"Duplicate Filter registration for '" + filterName
+ "'. Check to ensure the Filter is only configured once.");
}
registration.setAsyncSupported(isAsyncSessionSupported());
EnumSet<DispatcherType> dispatcherTypes = getSessionDispatcherTypes();
registration.addMappingForUrlPatterns(dispatcherTypes, !insertBeforeOtherFilters,
"/*");
}
开发者ID:spring-projects,项目名称:spring-session,代码行数:24,代码来源:AbstractHttpSessionApplicationInitializer.java
示例12: contextInitialized
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
this.instance = createHazelcastInstance();
Map<String, Session> sessions = this.instance.getMap(SESSION_MAP_NAME);
MapSessionRepository sessionRepository = new MapSessionRepository(sessions);
SessionRepositoryFilter<? extends Session> filter = new SessionRepositoryFilter<>(
sessionRepository);
Dynamic fr = sce.getServletContext().addFilter("springSessionFilter", filter);
fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
}
示例13: configureCors
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
private void configureCors(Environment environment) {
Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
filter.setInitParameter("allowedHeaders", "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
filter.setInitParameter("allowCredentials", "true");
}
示例14: onStartup
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
/**
* A Molgenis common web application initializer
*/
protected void onStartup(ServletContext servletContext, Class<?> appConfig, int maxFileSize)
{
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(appConfig);
// Manage the lifecycle of the root application context
servletContext.addListener(new ContextLoaderListener(rootContext));
// Register and map the dispatcher servlet
DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext);
dispatcherServlet.setDispatchOptionsRequest(true);
// instead of throwing a 404 when a handler is not found allow for custom handling
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
ServletRegistration.Dynamic dispatcherServletRegistration = servletContext.addServlet("dispatcher",
dispatcherServlet);
if (dispatcherServletRegistration == null)
{
LOG.warn("ServletContext already contains a complete ServletRegistration for servlet 'dispatcher'");
}
else
{
final long maxSize = (long) maxFileSize * MB;
dispatcherServletRegistration.addMapping("/");
dispatcherServletRegistration.setMultipartConfig(
new MultipartConfigElement(null, maxSize, maxSize, FILE_SIZE_THRESHOLD));
}
// add filters
Dynamic browserDetectionFiler = servletContext.addFilter("browserDetectionFilter",
BrowserDetectionFilter.class);
browserDetectionFiler.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
Dynamic etagFilter = servletContext.addFilter("etagFilter", ShallowEtagHeaderFilter.class);
etagFilter.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "dispatcher");
Dynamic corsFilter = servletContext.addFilter("corsFilter", CorsFilter.class);
corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/api/*");
corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/fdp/*");
// enable use of request scoped beans in FrontController
servletContext.addListener(new RequestContextListener());
servletContext.addListener(HttpSessionEventPublisher.class);
}
示例15: run
import javax.servlet.FilterRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void run(OregamiConfiguration config, Environment environment)
throws Exception {
environment.servlets().addFilter("persistFilter", guiceBundle.getInjector().getInstance(PersistFilter.class)).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
StartHelper.init(StartHelper.getConfigFilename());
DatabaseFiller databaseFiller = StartHelper.getInjector().getInstance(DatabaseFiller.class);
if (config.isInitBaseLists()) {
databaseFiller.initBaseLists();
}
if (config.isInitGames()) {
databaseFiller.initGameData();
}
databaseFiller.initDemoUser();
WebsiteHelper.init(config.getPhantomJSConfiguration().getPhantomjsCommandLocation(), config.getPhantomJSConfiguration().getRasterizeJSFileLocation());
MailHelper.init(config.getMailConfiguration());
Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
filter.setInitParameter(CrossOriginFilter.EXPOSED_HEADERS_PARAM, "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin,Location");
filter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin,Location");
filter.setInitParameter(CrossOriginFilter.ALLOW_CREDENTIALS_PARAM, "true");
//
// filter.setInitParameter("allow", "GET,PUT,POST,DELETE,OPTIONS");
// filter.setInitParameter("preflightMaxAge", "5184000"); // 2 months
environment.jersey().register(guiceBundle.getInjector().getInstance(GamesResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(HomeResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(AdminResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(PublicationFranchiseResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(WebsiteResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(UserResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(ScriptResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(TransliteratedStringResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(HardwarePlatformResource.class));
environment.jersey().register(createAuthProvider());
environment.jersey().register(guiceBundle.getInjector().getInstance(JWTResource.class));
}