【发布时间】:2018-11-28 18:45:44
【问题描述】:
你能帮帮我吗? 我想从产品中展示我的前 3 个对象,但我不知道它必须是怎样的。 我尝试使用百里香序列,但它不起作用。也许有人可以提示我如何做到这一点。
HTML:
<th:block th:each="product:${products}">
<a th:class="production_Page" th:href="@{'product/'+${product.id}}"> <p
th:text="${product.productName}"/></a>
<a th:class="production_Page"
th:href="@{'productDelete/'+${product.id}}">Delete</a>
<a th:class="production_Page"
th:href="@{'productEdit/'+${product.id}}">Edit</a>
<img th:class="productImage" th:src="${product.pathImage}"/>
<br/>
</th:block>
控制器:
@GetMapping("/products")
public String seeAllProductsIntoAList(Model model){
model.addAttribute("products", productService.findAll());
model.addAttribute("categories", categoryService.findAll());
return "/productView/products";
}
如果有人能提示我这个问题,那就太好了。
谢谢。
【问题讨论】:
-
productService.findAll()会返回什么? -
@Override public List
findAll() { return dao.findAll(); }
标签: java spring spring-mvc spring-boot thymeleaf