Spring Boot + Mustache:仅在用户通过身份验证时呈现html

问题描述 投票:0回答:1

这似乎是一个简单的任务,但我还没有找到一个直接的答案如何做到这一点。我在一个小的Spring Boot应用程序中使用Mustache。在我的标题部分我想仅在用户通过身份验证时呈现注销链接。我怎样才能做到这一点?

spring-boot spring-security kotlin mustache
1个回答
0
投票

如果您的视图中有一个映射对象,例如“userObject”,您可以这样做:

{{^userObject}}<a href='/login'>Login</a>{{/userObject}}{{#userObject}}<a href='/logout'>logout</a>{{/userObject}}
© www.soinside.com 2019 - 2024. All rights reserved.