Spring Data Rest Interceptor不适用于CustomController

时间:2015-10-07 18:21:55

标签: spring-data-rest

我有一个spring数据REST应用程序,我在其中添加了一个用于身份验证的拦截器。授权。

= 8 + ( "recursion starting from 7")
= 8 + ( -7 + "recursion starting from 6")
...
= 8 + ( -7 + -6 + -5 + -4 + -3 + -2 + "recursion starting from 1")
= 8 + ( -7 + -6 + -5 + -4 + -3 + -2 + -1 + "recursion starting from 0")
= 8 + ( -7 + -6 + -5 + -4 + -3 + -2 + -1 + -0 /* end case */ )

在这个应用程序中,我也有很少的控制器。其中一些是@RepositoryRestController&其他是@BasePathAwareController。我想在请求到达这些控制器时调用拦截器。对于@RepositoryRestController,拦截器被调用,但对于@BasePathAwareController,它被绕过。 如何为两个控制器类调用此拦截器?

1 个答案:

答案 0 :(得分:0)

通过添加映射拦截器来解决此问题(感谢llya为您的输入)。在配置类中,我添加了以下映射拦截器。通过这种方式,它将被调用所有来自任何控制器的请求。

@Bean
    public MappedInterceptor myMappedInterceptor() {
        return new MappedInterceptor(new String[]{"/**"}, getSecurityInterceptor());
    }

参考 How to add Custom Interceptor in Spring data rest (spring-data-rest-webmvc 2.3.0)