Spring Security redirect to previous page after successful login

前端 未结 9 1182
孤独总比滥情好
孤独总比滥情好 2020-11-27 10:09

I know this question has been asked before, however I\'m facing a particular issue here.

I use spring security 3.1.3.

I have 3 possible login cases in my web

9条回答
  •  悲哀的现实
    2020-11-27 10:56

    In order to redirect to a specific page no matter what the user role is, one can simply use defaultSucessUrl in the configuration file of Spring.

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        
        
          http.authorizeRequests() 
          .antMatchers("/admin").hasRole("ADMIN") 
          .and()
          .formLogin() .loginPage("/login") 
                        .defaultSuccessUrl("/admin",true)
          .loginProcessingUrl("/authenticateTheUser")
          .permitAll();
         
        
    

提交回复
热议问题