在 th:each 中,可以使用 th:remove 标签来移除当前标签,如下所示:

<th:block th:each="book:${randomByPrice}">
    <div th:remove="tag">
        <p th:text="${book.title}"></p>
        <p th:text="${book.author}"></p>
    </div>
</th:block>

这样就可以在生成时去除多余的 div 标签了。

Thymeleaf th:each 中如何移除多余标签

原文地址: https://www.cveoy.top/t/topic/nJVn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录