Has*_*lah 1 spring spring-mvc thymeleaf
我有一个 th:each 循环,其中一个显示按钮。
<li th:id="${'button-' + row.name }" th:unless="${row.name == 'linkedin' or row.name == 'slideshow'}" class="collection-item avatar" th:each="row, rowStat: *{arButtons}">
        <img th:src="${'/images/buttons/' + row.name + '.png'}" th:alt="${row.name}" class="circle"/>
            <div class=" input-field col s12">
                <input th:field="*{arButtons[__${rowStat.index}__].name}" type="hidden" />
                <input th:field="*{arButtons[__${rowStat.index}__].data}" th:id="${'button-'+rowStat.index}" type="text" class="validate" /> 
                <label th:if="${row.name == 'call'}" th:for="${'button-'+rowStat.index}" th:text="${call}"> Phone number </label>
                <label th:if="${row.name == 'mail'}" th:for="${'button-'+rowStat.index}" th:text="${mail}"> Email </label>
                <label th:if="${row.name == 'link'}" th:for="${'button-'+rowStat.index}" th:text="${link}"> Web Link </label>
                <label th:if="${row.name == 'video'}" th:for="${'button-'+rowStat.index}" th:text="${video}"> Video </label>
            </div>
        </li>
现在我不想每次都使用来检查 row.name 以显示方便的文本有没有办法使用类似的东西
<label th:for="${'button-'+rowStat.index}" th:text="${${row.name}}">  </label>
请有任何想法!
查看 Thymeleaf 的预处理功能。对于你的情况,我认为
th:text="${__(${row.name})__}"
请注意,您应该使用双下划线,括号可以省略,但对我来说更清楚
| 归档时间: | 
 | 
| 查看次数: | 6005 次 | 
| 最近记录: |