我想使用thymeleaf th:each在li标签中显示图像。 我试图将数字的变量值输入到图像src中,但未显示图像。 如何对每个数字变量输入图像src进行百里香素?
尝试代码:
<th:block th:each="num: ${#numbers.sequence(1,22)}">
<li>
<img th:src="@{/images/sub/logo/company + ${num} + .jpg}">
</li>
</th:block>
and
<li th:each="num: ${#numbers.sequence(1,22)}">
<img th:src="@{/images/sub/logo/company + ${num} + .jpg}">
</li>
错误: http://localhost:8090/ **** / images / sub / logo / company%20 +%20 $%7Bnum%7D%20 +%20.jpg
答案 0 :(得分:0)
<li th:each="num: ${#numbers.sequence(1,22)}">
<img th:src="@{/images/sub/logo/company{i}.jpg(i=${num})}">
</li>