Logged in redirection in spring secutiry - SoftLabio

Ads Here

Monday, September 9, 2019

Logged in redirection in spring secutiry




In controller class, write a function for your login page:

public String anyController(your defined parameters ....){

     Authentication auth = SecurityContextHolder.getContext().getAuthentication();
     if (!(auth instanceof AnonymousAuthenticationToken)) {
      
         /* The user is logged in :) */
          return new ModelAndView("forward:/index");
     }
      
     // write your other code here
     return "";
 }




No comments:

Post a Comment