Method 1
Authentication auth = SecurityContextHolder.getContext().getAuthentication();Method 2
String name = auth.getName(); //get logged in username
User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();String name = user.getUsername(); //get logged in username
http://www.mkyong.com/spring-security/get-current-logged-in-username-in-spring-security/
沒有留言:
張貼留言