sitemesh + spring security:在主装饰页面中显示登录用户!

Posted

技术标签:

【中文标题】sitemesh + spring security:在主装饰页面中显示登录用户!【英文标题】:sitemesh + spring security: show logged in user in main decorator page! 【发布时间】:2011-03-28 21:01:02 【问题描述】:

我想在主装饰页面中显示登录用户。 我用:

<decorator:usePage id="myPage"/>
Logged in as:<%= myPage.getRequest().getUserPrincipal().getName()%>
<decorator:body/>

但不行!

【问题讨论】:

【参考方案1】:

已经有一段时间没有使用 SiteMesh,但是您为什么不使用隐式 request 对象(我假设您的页面是用 JSP 编写的,对吗?)

<%= request.getUserPrincipal().getName() %>

究竟是什么不工作?是否抛出异常?

【讨论】:

【参考方案2】:

您需要将 SiteMesh 过滤器映射放在 Spring Security 过滤器映射下方。

见:Spring security tags in sitemesh decorator

【讨论】:

以上是关于sitemesh + spring security:在主装饰页面中显示登录用户!的主要内容,如果未能解决你的问题,请参考以下文章

如何在sitemesh装饰器中获取模型属性或spring的bean?

Spring Session 不适用于 Sitemesh

如何将 Sitemesh 3 与 Spring MVC 3 集成?

sitemesh + spring security:在主装饰页面中显示登录用户!

Spring Security 应用程序中的 Sitemesh 未装饰自定义错误页面

Sitemesh 都有哪些替代方案来帮助在 Spring MVC 应用程序中布局 JSP/JSTL 页面页脚/页眉?