我想在登录后留在同一页面,但 spring 要求你重定向到 defaultSuccessUrl
我的代码是这样的
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/css/**","/fonts/**","/js/**","/app/**","/images/**","/partials/**").permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/index.html")
.failureUrl("/login?error=true")
.permitAll()
.and().logout().logoutSuccessUrl("/login?logout")
.and().exceptionHandling().accessDeniedPage("/pages/303.html");
}
最佳答案
设置
always-use-default-target="true"
这将强制 spring-security 转到/index.html
关于java - 登录 Spring security 后保留相同的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39789350/