By arunraj
To get currently logged in user details in a JSP, use the following tag
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<security:authentication property="principal.username" />
<security:authentication property="principal.username" />
Using the security authentication tag which is a part of spring security framework, you can access all the properties of the User. Provided the User bean should implement UserDetailsService interface of Spring Security.
public class User implements UserDetails, Serializable {
private Long id;
private String username;
private String password;
// add other properties along with getter and setter methods
}
private Long id;
private String username;
private String password;
// add other properties along with getter and setter methods
}