【问题标题】:Thymeleaf th:block conditionThymeleaf th:阻塞条件
【发布时间】: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


【解决方案1】:

问题是您在这一行中添加了一个额外的大括号:

<th:block th:if="${StatusFormation}} =='Traitement' }">

你应该把它改成:

<th:block th:if="${StatusFormation} == 'Traitement'">

【讨论】:

  • 引起:org.thymeleaf.exceptions.TemplateProcessingException:无法解析为表达式:“${formations.StatusFormation} =='Traitement'}”(模板:“ChefProjetFormationHome” - 第 29 行,col 11)我有这个问题!谢谢你的回复!
  • 你好,是的,代码有效,但我没有在我的桌子上看到数据 thymleaf 不要使用我的条件
猜你喜欢
  • 1970-01-01
  • 2021-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-22
  • 2018-04-26
相关资源
最近更新 更多