根据您的回复,我认为这些方法可能有效:
product.get(0, Product.class)
<!-- Note, you have to replace your.package.Product with the actual package -->
<div th:each="product :${products}" th:with="class=${T(your.package.Product).class}">
<h2 th:text="${product.get(0, class)}" />
</div>
product.get(qProduct.title)
<!-- For this, you need to add qProduct on the model -->
<div th:each="product :${products}">
<h2 th:text="${product.get(qProduct.title)}" />
</div>
您也可以使用toArray(),但我不完全确定结果如何:
<div th:each="product :${products}" th:with="data=${product.toArray()}">
<h2 th:text="${data[0]}" />
</div>