반응형

스프링부트에서 필터를 등록하는 방법입니다.



import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
 
  // ...
 
  @Bean
  public FilterRegistrationBean getFilterRegistrationBean() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean(new XSSFilter());
    registrationBean.setOrder(Integer.MIN_VALUE);
    registrationBean.addUrlPatterns("/*");
    return registrationBean;
  }
 
  // ...
}



반응형

+ Recent posts