【发布时间】:2019-10-17 05:44:11
【问题描述】:
我想像这样在 Thymeleaf 模板上设置一些条件,但它不起作用。
<table border=2>
<thead>
<tr>
<td> Identifiant </td>
<td> Nom Formation </td>
<td> Descirption Formation </td>
<td> Adresse Formation </td>
<td>Status Formation </td>
<td> Chef Projet </td>
<td> Formateur </td>
<td>Ressource Humain</td>
<td>Update</td>
<td>Liste Devellopeur</td>
</tr>
</thead>
<tbody>
<tr th:each="formations : ${formations}">
<th:block th:if="${StatusFormation}} =='Traitement' }">
<td th:text="${formations.id}"> </td>
<td th:text="${formations.NomFormation}"> </td>
<td th:text="${formations.DescriptionFormation}"> </td>
<td th:text="${formations.StatusFormation}"> </td>
<td th:text="${formations.AdresseFormation}"> </td>
<td th:text="${formations.chef_projet}"> </td>
<td th:text="${formations.formateurs}"> </td>
<td th:text="${formations.ressourcehumain}"> </td>
</th:block>
</tr>
</tbody>
</table>
错误是 原因:org.thymeleaf.exceptions.TemplateProcessingException:无法解析为表达式:“${StatusFormation}} =='Traitement'}”(模板:“ChefProjetFormationHome” - 第 29 行,第 11 列)在 org.thymeleaf.standard。表达式.StandardExpressionParser.parseExpression(StandardExpressionParser.java:131)
【问题讨论】:
-
th:if表达式中有两个额外的花括号......th:if="${formations.StatusFormation == 'Traitement'}"应该可以工作。 -
我解决了这个问题:原因:org.attoparser.ParseException:无法解析为表达式:“${formations.StatusFormation}} =='Traitement'}”(模板:“ChefProjetFormationHome”-第 29 行,第 11 列)
标签: spring-boot spring-mvc conditional-statements thymeleaf