转至: http://blog.csdn.net/chenyongsuda/article/details/5327059
1. 在session中取得spring
security的登录用户名如下
${session.SPRING_SECURITY_CONTEXT.authentication.principal.username}
2. 在页面端用tag获取
<%@ taglib prefix='security'
uri='http://www.springframework.org/security/tags'%>
<security:authentication
property="principal.username"></security:authentication>
3. 在后台获取
UserDetails userDetails = (UserDetails)
SecurityContextHolder.getContext().getAuthentication().getPrincipal();
userDetails.getUsername();
版权声明:本文为博主原创文章,未经博主允许不得转载。