【发布时间】:2011-12-31 00:50:22
【问题描述】:
我对此感到困惑。我已经成功设置了 Spring Security(基于角色的访问等),但我不明白如何向 Spring 创建的会话添加一些内容?或者我应该使用另一个会话来存储 DTO 属性?如果我使用自己的会话,Spring Security 会保护它吗?它对我一点也不透明:
<p id="layoutdims">
<strong>
Logged in as <security:authentication property="principal.username" />
</strong>
<strong>
Logged in as <% HttpSession hs = request.getSession(); %>
<%=hs.getAttribute("principal.username") %>
</strong>
</p>
如果 Spring Security 使用主会话,为什么 hs.getAttribute 给我 null?我对此感到非常愚蠢,尤其是当我完成了最复杂的部分时。
【问题讨论】: