本文整理汇总了Java中org.springframework.boot.web.servlet.FilterRegistrationBean.setOrder方法的典型用法代码示例。如果您正苦于以下问题:Java FilterRegistrationBean.setOrder方法的具体用法?Java FilterRegistrationBean.setOrder怎么用?Java FilterRegistrationBean.setOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.web.servlet.FilterRegistrationBean
的用法示例。
在下文中一共展示了FilterRegistrationBean.setOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: corsFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
FilterRegistrationBean corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
}
示例2: corsFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addExposedHeader("WWW-Authenticate");
config.addExposedHeader("Access-Control-Allow-Origin");
config.addExposedHeader("Access-Control-Allow-Headers");
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
source.registerCorsConfiguration("/**", config);
final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}
示例3: corsFilterBean
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
/**
* <a href="https://github.com/spring-projects/spring-boot/issues/5834#issuecomment-296370088">See explanation here</a>
*/
@Bean
public FilterRegistrationBean corsFilterBean() {
final CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Collections.singletonList("*"));
configuration.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"));
// setAllowCredentials(true) is important, otherwise:
// The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
configuration.setAllowCredentials(true);
// setAllowedHeaders is important! Without it, OPTIONS preflight request
// will fail with 403 Invalid CORS request
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type"));
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
FilterRegistrationBean corsFilter = new FilterRegistrationBean(new CorsFilter(source));
corsFilter.setOrder(Ordered.HIGHEST_PRECEDENCE);
return corsFilter;
}
示例4: setRestApiFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean setRestApiFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(historyFilter);
registration.addUrlPatterns("/api/engine/engine/default/task/*");
registration.setName("historyFilter");
registration.setOrder(Integer.MAX_VALUE - 1);
return registration;
}
示例5: someFilterRegistration
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
/**
* Some filter registration filter registration bean.
*
* @return the filter registration bean
*/
@Bean
public FilterRegistrationBean someFilterRegistration() {
final FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(etagFilter());
registration.addUrlPatterns("/api/*");
registration.setName("etagFilter");
registration.setOrder(1);
return registration;
}
示例6: corsFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}
示例7: filterRegistrationBean
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean registration = new FilterRegistrationBean(new SessionFilter(this));
registration.addUrlPatterns("/*");
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
return registration;
}
示例8: corsFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**/bundle.json", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}
示例9: objectifyFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean objectifyFilter(){
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new ObjectifyFilter());
registration.addUrlPatterns("/*");
registration.setOrder(1);
return registration;
}
示例10: corsFilter
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source =
new UrlBasedCorsConfigurationSource();
CorsConfiguration config =
new CorsConfiguration().applyPermitDefaultValues();
config.addAllowedMethod(HttpMethod.PUT);
config.addAllowedMethod(HttpMethod.PATCH);
config.addAllowedMethod(HttpMethod.DELETE);
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(
new CorsFilter(source));
bean.setOrder(0);
return bean;
}
示例11: restFilterRegistration
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean restFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(restFilter());
registration.addUrlPatterns("/rest/*");
registration.setName("RESTFilter");
registration.setOrder(3);
return registration;
}
示例12: oauth2ClientFilterRegistration
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean oauth2ClientFilterRegistration(
OAuth2ClientContextFilter filter) {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(filter);
registration.setOrder(-100);
return registration;
}
示例13: characterEncodingFilterRegistration
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean characterEncodingFilterRegistration() {
FilterRegistrationBean registrationBean =
new FilterRegistrationBean(characterEncodingFilter());
registrationBean.setName("CharacterEncodingFilter");
registrationBean.addUrlPatterns("/*");
registrationBean.setOrder(1);
return registrationBean;
}
示例14: xssFilterRegistration
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean xssFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter());
registration.addUrlPatterns("/*");
registration.setName("xssFilter");
registration.setOrder(Integer.MAX_VALUE);
return registration;
}
示例15: xAPIValidationFilterBean
import org.springframework.boot.web.servlet.FilterRegistrationBean; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean xAPIValidationFilterBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(xAPIRequestValidationFilter);
List<String> urls = new ArrayList<String>(1);
urls.add("/xAPI/*");
registrationBean.setUrlPatterns(urls);
registrationBean.setOrder(3);
return registrationBean;
}