在jsp中获取SpringSecurity中已登录的用户的用户名

1.先引入secrity的标签库

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

2.获取值

<security:authentication property="principal.username"/>

在IDEA的自动提示里面,会直接提示出username,千万不要忘了写principle

猜你喜欢

转载自www.cnblogs.com/rao11/p/11798475.html