如果用户尚未验证他的电子邮件,我将尝试显示消息
在我的 Controller 中我有
model.addAttribute("user", auth.getUser());
在我的模板中是
<div th:if="${!user.isEmailValidated()}" class="div-block-10">
<div class="user_name" th:text="${Your email is not confirmed!}">Email validated</div>
</div>
我不知道我哪里做错了
最佳答案
如果您不想翻译您的消息,您可以这样做:
<div th:if="${!user.isEmailValidated()}" class="div-block-10">
<div class="user_name">Your email is not confirmed!</div>
</div>
如果您想翻译它,请使用 fragments of template code像这样:
<div th:if="${!user.isEmailValidated()}" class="div-block-10">
<div class="user_name" th:text="#{email.not_confirmed}">Email not confirmed</div>
</div>
并在 WEB-INF/templates/email_en.properties
中使用值 您的电子邮件未确认!
创建 key email.not_confirmed
。这只是一个例子。
请注意,使用 $
(用于变量)和 #
(用于代码片段)之间存在差异。您不能在 ${}
语句内写入文本。
关于java - thymeleaf 中的 if 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50332807/