HTML,Thymeleaf - 有条件地显示图像

时间:2017-05-25 20:55:01

标签: html thymeleaf

我的任务是显示星级评分。

如果评级没有以零结尾,我想显示半星。

如果数字以零结尾,则“odd”属性包含零。

我需要'if'语句的帮助。

<tr th:each="comp : ${companies}">

    <td">
        <img th:src="@{/images/star.png}"
             th:each="star:${#numbers.sequence(1, comp.avgRating)}">

        <img th:src="@{/images/halfstar.png}"     

    th:if="${comp.odd &gt; 0}" ? th:each="halfstar:${#numbers.sequence(0, comp.odd)}"> 

    </td>
</tr>

一些想法?

0 个答案:

没有答案