在SSM框架中bean的配置是放在xml中的,springboot项目通过@bean在config配置类中将过滤器注入进去。代码如下
@Bean
public FilterRegistrationBean cas20ProxyReceivingTicketValidationFilter() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
//配置拦截器参数map
Map<String, String> map = new HashMap<>(16);
Cas20ProxyReceivingTicketValidationFilter cas20ProxyReceivingTicketValidationFilter = new Cas20ProxyReceivingTicketValidationFilter();
filterRegistrationBean.setFilter(cas20ProxyReceivingTicketValidationFilter);
map.put("casServerUrlPrefix", "***************");
map.put("serverName", "***************");
map.put("redirectAfterValidation", "***************");
map.put("encoding", "UTF-8");
filterRegistrationBean.setInitParameters(map);
String url = "/*";
filterRegistrationBean.addUrlPatterns(url);
filterRegistrationBean.setName("Cas20ProxyReceivingTicketValidationFilter");
return filterRegistrationBean;
}