如何在Thymeleaf中拆分字符串

mik*_*ang 7 split thymeleaf

我有imageNames喜欢wange/25011.jpg|wange/25011-1.jpg或null,我想将它们拆分为wange/25011.jpgwange/25011-1.jpg,或者如果为null则不拆分.我尝试了如下代码,但没有工作......

<td th:if="${brickset.imageNames} != null"  th:each="image : ${#strings.arraySplit(brickset.imageNames, '|')}">
    <a href="#" th:href="${imageBaseUrl + image}">
        <img src="#" th:src="${imageBaseUrl + image}" height="64"/>
    </a>
</td> 
Run Code Online (Sandbox Code Playgroud)

mik*_*ang 10

这是我自己的答案:

<tbody id="portfolio" class="clear fix">
  <tr th:each="brickset : ${bricksets}" th:alt="${brickset.description}">
    <td>
      <div th:unless="${brickset.imageNames == null}">
        <div th:each="image,status : ${#strings.arraySplit(brickset.imageNames, '|')}">
          <a href="#" th:href="${imageBaseUrl + image}" th:remove="${image} == null ? tag" th:title="${brickset.brand.name}">
            <img src="#" th:src="${imageBaseUrl + image}" height="64" th:remove="${status.index} > 0 ? tag"/>
          </a>
        </div>
      </div>
    </td>
  </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)