Spring security TILEL获取spring安全主体对象

Spring security TILEL获取spring安全主体对象,spring-security,tiles2,Spring Security,Tiles2,我有项目running spring和tiles2和Thymeleaf模板引擎。 在tiles中,我想根据用户是否经过身份验证来显示身份验证导航栏,为此,我使用ApacheTiles EL来选择要选择的导航栏。 这是我的定义 `<definition name="abstract.layout" template="/layouts/abstractLayout" templateType="thymeleaf" > <put-attribute name="navba

我有项目running spring和tiles2和Thymeleaf模板引擎。 在tiles中,我想根据用户是否经过身份验证来显示身份验证导航栏,为此,我使用ApacheTiles EL来选择要选择的导航栏。 这是我的定义

`<definition name="abstract.layout" template="/layouts/abstractLayout" templateType="thymeleaf" >
    <put-attribute name="navbar" type="definition" expression="${principal} !=null ? 'authenticated.navbar' : 'guest.navbar'" />

    <put-attribute name="title" value="company" type="string" />
    <put-attribute name="description" value="E-Commerce Platform" type="string" />
    <put-attribute name="sidebar" value="/layouts/fragments/sidebar/sidebar::content" type="thymeleaf"  />
    <put-attribute name="footer" value="/layouts/fragments/footer::content" type="thymeleaf" />

    <put-list-attribute name="thirdPartyCssFiles" >
    </put-list-attribute>
    <put-list-attribute name="customCssFiles">
    </put-list-attribute>
    <put-list-attribute name="pluginJsFiles">
    </put-list-attribute>
    <put-list-attribute name="customJsFiles">
    </put-list-attribute>
</definition>`
`
`
当我计算磁贴时,在计算上下文中找不到变量${principal}

我的问题是:

  • 如何获取spring安全主体对象以及如何知道用户是否经过身份验证
  • 有没有一种方法可以在表达式中使用SPEL而不是EL或ONGL
多谢各位