public BaseApplicaionConfig() { //设置默认时区 System.setProperty("user.timezone", "Asia/Shanghai"); register(ValidationContextResolver.class); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true); this.packages(packages()); register(ObjectMapperResolver.class); register(JacksonFeature.class); register(JacksonJsonProvider.class); register(new BaseExceptionMapper(createExcetionWrapper())); register(RequestContextFilter.class); register(DefaultWebFilter.class); if (FilterConfig.apiDocEnabled()) { register(SwaggerSerializers.class); } }
public BaseApplicaionConfig() { //设置默认时区 System.setProperty("user.timezone","Asia/Shanghai"); register(ValidationContextResolver.class); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true); this.packages(packages()); register(ObjectMapperResolver.class); register(JacksonFeature.class); register(JacksonJsonProvider.class); register(new BaseExceptionMapper(createExcetionWrapper())); register(RequestContextFilter.class); register(DefaultWebFilter.class); // if(FilterConfig.apiDocEnabled()){ register(SwaggerSerializers.class); } }
@Override public void onStartup(ServletContext servletContext) throws ServletException { Map<String, String> filterChainDefinitionMap = Application.getSecurityFilterChainDefinitionMap(); filterChainDefinitionMap.put("/admin", DefaultFilter.authc.name()); filterChainDefinitionMap.put("/admin/logout", DefaultFilter.logout.name()); filterChainDefinitionMap.put("/admin/**", DefaultFilter.authc.name()); List<Filter> filters = Application.getFilters(); DelegatingFilterProxy shiroFilter = new DelegatingFilterProxy("shiroFilter"); shiroFilter.setTargetFilterLifecycle(true); filters.add(shiroFilter); filters.add(new RequestContextFilter()); filters.add(new CharacterEncodingFilter("UTF-8", true)); }
@Bean public FilterRegistrationBean requestContextFilter() { final FilterRegistrationBean filterRegBean = new FilterRegistrationBean(); filterRegBean.setFilter(new RequestContextFilter()); filterRegBean.addUrlPatterns("*"); filterRegBean.setEnabled(Boolean.TRUE); filterRegBean.setName("RequestContextFilter"); return filterRegBean; }
public ApplicationConfig() { System.setProperty("user.timezone", "Asia/Shanghai"); this.packages(new String[]{this.getClass().getPackage().getName()}); this.register(ObjectMapperResolver.class); this.register(JacksonFeature.class); this.register(JacksonJsonProvider.class); this.register(BaseExceptionMapper.class); this.register(RequestContextFilter.class); //this.register(CorsFilter.class); register(FormatJsonDynamicFeature.class); }
@Bean @ConditionalOnMissingBean public FilterRegistrationBean requestContextFilter() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new RequestContextFilter()); registration.setOrder(this.jersey.getFilter().getOrder() - 1); registration.setName("requestContextFilter"); return registration; }
/** * <p>默认关闭<p> * 加载RequestContextFilter 用于将RequestContext存储于当前线程 * @param servletContext */ protected void initRequestContextFilter(ServletContext servletContext){ String enableRequestContextFilter = servletContext.getInitParameter("enableRequestContext"); if(BooleanUtils.valueOf(enableRequestContextFilter)){ //RequestContextFilter RequestContextFilter requestContextFilter = new RequestContextFilter(); FilterRegistration filterRegistration = servletContext.addFilter("requestContextFilter", requestContextFilter); filterRegistration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*"); } }
@PostConstruct private void initialize() { mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) .addFilter(new RequestContextFilter()) .addFilter(springSecurityFilterChain) .build(); mockSession = new MockHttpSession(webApplicationContext.getServletContext(), UUID.randomUUID().toString()); }
public JerseyConfig() { System.out.println("Initializing JerseyConfig"); register(RequestContextFilter.class); // NOTE: scanning does not appear to work with java jar launcher (as opposed to 'mvn springboot:run' which does) !? // Explicitly register all resources here instead :-( register(ActivityResource.class); register(AlmanacResource.class); register(AuthenticationResource.class); register(GenericCommandResource.class); register(OrganizationResource.class); register(UniqueIdResource.class); register(UserResource.class); register(LoggingFilter.class); }
@Override protected Filter[] getServletFilters() { return new Filter[]{ new MDCInsertingServletFilter(), new HiddenHttpMethodFilter(), new OpenEntityManagerInViewFilter(), new RequestContextFilter(), new SecurityContextPersistenceFilter() }; }
@Bean public RequestContextFilter requestContextFilter() { return new RequestContextFilter(); }
@Bean @ConditionalOnMissingBean({ RequestContextListener.class, RequestContextFilter.class }) public static RequestContextFilter requestContextFilter() { return new OrderedRequestContextFilter(); }
@Bean @ConditionalOnMissingBean({ RequestContextListener.class, RequestContextFilter.class }) public RequestContextFilter requestContextFilter() { return new OrderedRequestContextFilter(); }
@Bean public RequestContextFilter registrationRequestFilter() { RequestContextFilter requestContextFilter = new RequestFilter(); return requestContextFilter; }