【问题标题】:spring using security:authentication principal.username in linkspring 在链接中使用 security:authentication principal.username
【发布时间】:2011-12-31 08:41:16
【问题描述】:
好的,这应该很容易
在 header.jspx 文件中,我想要一个链接,将经过身份验证的用户引导到他们的用户页面。
这是我用来检索用户名的:
<sec:authentication property="principal.username" />
这是我想把它放进去的:
<a href="http://localhost:8080/dealclick/users/username_here" > My account </a>
可以吗?
【问题讨论】:
标签:
java
jsp
spring-mvc
spring-security
【解决方案1】:
你试过了吗
<c:set var="username">
<sec:authentication property="principal.username" />
</c:set>
然后使用
<a href="http://localhost:8080/dealclick/users/${username}" > My account </a>
【解决方案2】:
您可以将其替换为:
<a href="http://localhost:8080/dealclick/users/<sec:authentication property="principal.username"/>" > My account </a>