简体   繁体   English

我可以在同一个 Spring Boot 应用程序上使用两个拦截器吗?

[英]Can I use two interceptors on same spring boot application?

I have a Spring Boot application that contains two different dashboards, and so each user can access only one.我有一个包含两个不同仪表板的 Spring Boot 应用程序,因此每个用户只能访问一个。 Actually I have one interceptor that secure one dashboard, but the second dashboard needs another interceptor.实际上我有一个拦截器来保护一个仪表板,但第二个仪表板需要另一个拦截器。 This is possible?这个有可能?

This is my configuration class:这是我的配置类:

@Configuration
public class SecurityConfiguration implements WebMvcConfigurer{

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AutorizadorInterceptorEscola());
    }
}

I need to add another interceptor to secure the second dashboard.我需要添加另一个拦截器来保护第二个仪表板。

Create Configuration Class extends with WebMvcConfigurerAdapter使用 WebMvcConfigurerAdapter 创建配置类扩展

@Override
public void addInterceptors(InterceptorRegistry registry) {
     registry.addInterceptor(new GuestInterceptor());
     registry.addInterceptor(new AdminInterceptor());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在Spring启动应用程序中使用Spring集成模块吗? - Can I use Spring integration modules in my Spring boot application? Spring 引导 - 模拟拦截器 - Spring Boot - Mock Interceptors 当 rest 模板具有使用 Spring 引导 1.5.x 的拦截器时,我们可以使用 @RestClientTest 吗? - Can we use @RestClientTest when the rest template has interceptors using Spring boot 1.5.x? 在Spring 4应用程序中声明拦截器 - Declaring interceptors in a spring 4 application Spring Boot - 按顺序打印拦截器 - Spring Boot - Print interceptors with ordering 如何在Spring Boot和Spring Data中使用两个Cassandra数据源? - How can I use two Cassandra datasources with Spring Boot and Spring Data? 如何在同一个 jvm 上运行两个 spring boot 应用程序? - How to run two spring boot application on a same jvm? 我可以在 android 中同时在两个应用程序中使用陀螺仪传感器吗? - Can I use gyroscope sensor in two application at same time in android? 我可以在同一个Swing应用程序中使用两种不同的外观吗? - Can I use two different look and feels in the same Swing application? 在春季启动时,如何使用@InitBinder验证程序在同一控制器中验证两个请求? - How can I validate two request in same controller with @InitBinder validator at Spring boot?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM