dimanche 30 avril 2017

How to make principle.getName() retrieve modified username in database?

While logged in, I changed the username in my web setting page. However, principal.getName() still returned the old username. principal.getName() will only return correct updated username after I log out and log in back to my website. Is there a way around it so principal.getName() will immediately return the new username after I changed it without needing to log out and log in back?

@RequestMapping("/")
public String showHome(Principal principal, Model model)
{
    String username = principal.getName();

    model.addAttribute("username", username);

    return "home";
}




Aucun commentaire:

Enregistrer un commentaire