【问题标题】:how to thymeleaf th:each number variable input image src?如何百里香th:每个数字变量输入图像src?
【发布时间】:2019-05-17 01:41:51
【问题描述】:

我想使用 thymeleaf th:each 在 li 标签中显示图像。 我试图将数字的变量值输入到图像 src 中,但没有显示图像。 如何thymeleaf th:each number variable input image 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

【问题讨论】:

    标签: thymeleaf


    【解决方案1】:

    the standard url syntax

    <li th:each="num: ${#numbers.sequence(1,22)}">
      <img th:src="@{/images/sub/logo/company{i}.jpg(i=${num})}">
    </li>
    

    【讨论】:

      猜你喜欢
      • 2014-09-21
      • 1970-01-01
      • 2021-02-26
      • 1970-01-01
      • 2019-11-25
      • 1970-01-01
      • 2017-07-31
      • 1970-01-01
      • 2017-04-17
      相关资源
      最近更新 更多