7 Mayıs 2018 Pazartesi

SpringMVC InterceptorRegistry Sınıfı

Kullanım
Şöyle yaparız
@Configuration
public class AppConfig implements WebMvcConfigurer {
  @Autowired
  private RateLimitInterceptor rateLimitInterceptor;

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(rateLimitInterceptor).addPathPatterns(“/**”);
  }
}
addInterceptors metodu
Şöyle yaparız.
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
  LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
  localeChangeInterceptor.setParamName("lang");

  return localeChangeInterceptor;
}


public void addInterceptors(InterceptorRegistry registry){
  registry.addInterceptor(localeChangeInterceptor());
}

Hiç yorum yok:

Yorum Gönder