I am developing a spring-boot service that contains two filters (implements the javax.servlet.Filter interface). Although one filter should apply to all url patterns, I want to configure the second filter only on the url /api/* pattern.
I am currently doing this using the following code:
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public FilterRegistrationBean filterRegistrationBean() { FilterRegistrationBean registrationBean = new FilterRegistrationBean(); SecurityFilter securityFilter = new SecurityFilter(); registrationBean.setFilter(securityFilter); registrationBean.addUrlPatterns("/api/*"); return registrationBean; } }
But my question is, is there an annotation to do the same, given that there are annotations for setting the order of the filters ( @Order(..) ). I tried using javax.servlet.annotation.WebFilter , but spring-boot seems to ignore this annotation.
flomm source share