Get User Details in JSP?

后端 未结 1 1844
生来不讨喜
生来不讨喜 2021-01-25 17:49

How can get and show username, email, ip etc. of User which got below result in${pageContext.request.userPrincipal} ?

org.springframework.sec

相关标签:
1条回答
  • 2021-01-25 18:35

    You should use Spring Security JSP tags.

    First declare the correct taglib:

    <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
    

    and then use the following code to display for example the email of the current user.

    <sec:authentication property="principal.email" />
    

    You can substitute email for any property of your principal object (username, firstName, etc.).

    More information about Spring Security JSP tags can be found in the documentation:

    http://docs.spring.io/spring-security/site/docs/3.0.x/reference/taglibs.html

    0 讨论(0)
提交回复
热议问题