弹簧靴:访问DeniedHandler不起作用
2022-09-02 22:59:14
我有以下Spring Security配置:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/api/private/**", "/app/**").authenticated();
http.csrf().disable();
http.logout().logoutSuccessUrl("/");
http.exceptionHandling().accessDeniedPage("/403"); //.accessDeniedHandler(accessDeniedHandler);
}
}
我期望以下逻辑:未经身份验证的用户将被重定向到。而不是那个 Spring 显示默认的 Tomcat 403 页面。我也尝试过定制,尽管取得了任何成功。/403
accessDeniedHandler
如何在访问失败时实现自定义逻辑?