我正在开发一个 Spring Boot 项目和用于会话控制的 WebSecurityConfig。问题是,当会话过期时,我被重定向到/?sessionexpired我期望它应该重定向 o 的时候/?expiredsession。此外,当用户注销时,页面会重定向到/?sessionexpired而不是/?logout.我的配置如下 @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/thirdparty/**", "/webjars/**", "/sessionerror").permitAll() .anyRequest().authenticated() .and() .formLogin() .loginPage("/") .failureUrl("/?error") .defaultSuccessUrl("/dashboard") .permitAll() .and() .logout() .logoutUrl("/logout") .logoutSuccessUrl("/?logout") .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) // override default of only allowing POST for logout so we can use a GET .deleteCookies("remove") .invalidateHttpSession(true) .permitAll() .and() .sessionManagement() .maximumSessions(1) .expiredUrl("/?expiredsession") .maxSessionsPreventsLogin(false) .and() .invalidSessionUrl("/?sessionexpired"); }有人可以帮我解决这个问题吗?
1 回答

白衣非少年
TA贡献1155条经验 获得超0个赞
所以我最终想通了。它正在重定向,/?sessionexpired
因为在注销时我通过将其设置为 true 来使Session失效。我应该将其设置为 false,然后用于.deleteCookies("JSESSIONID")
使会话无效。这样它就会正确重定向。
添加回答
举报
0/150
提交
取消