拦截器拦截路径写法分析

2019-10-18  本文已影响0人  自由主义者

.antMatchers( "/api/","/xhh/user/","/user/**")说明

如果写成" /user/ ",只能识别/user一层
如果写成" /user/* ",只能识别两层
如果写成” /user/** ",可以识别很多层

 @Override
    protected void configure(HttpSecurity http) throws Exception {
        //TODO: 方便开发使用POSTMAN调试
        http.httpBasic();
        //必须放在super前面
        http.authorizeRequests()
            //.antMatchers("/userinfo")
            //.permitAll()
            .antMatchers( "/api/**","/xhh/user/**","/user/**")
            .permitAll();
        super.configure(http);
        http.authorizeRequests().anyRequest().authenticated()
            .and()
            .rememberMe()
            .and()
            .sessionManagement().invalidSessionStrategy(new AjaxInvalidSessionStrategy())
            .and()
            .logout().logoutUrl(properties.getLogoutUrl())
            .logoutSuccessHandler(logoutSuccessHandler).permitAll();
        http.exceptionHandling()
            .authenticationEntryPoint(new AjaxEntryPoint())
            .accessDeniedHandler(accessDeniedHandler);
    }
上一篇 下一篇

猜你喜欢

热点阅读