如果在百里香的陈述

时间:2018-05-14 14:28:52

标签: java spring thymeleaf

如果用户没有验证他的电子邮件,我正在尝试显示消息

在我的控制器中我有

 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>

我不确定我在哪里做错了

1 个答案:

答案 0 :(得分:3)

如果您不想翻译邮件,可以这样做:

 <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>

email.not_confirmed中创建值为Your email is not confirmed!的密钥WEB-INF/templates/email_en.properties。这只是一个例子。

请注意,使用$(对于变量)和#(对于代码片段)之间存在差异。您不能在${}语句中写入文本。