[英]How i can get tuple value (querydsl) since thymeleaf?
i don'i know how i get the tuple value of queryDSL since thymeleaf 我不知道自百里香以来我如何获得queryDSL的元组值
since backEnd i send this value: 由于backEnd我发送此值:
List<Tuple> products = productServiceImpl.findProductByFiltersPaginate(null, 0, 1, null);
ModelAndView view = new ModelAndView();
view.addObject("products",products);
view.setViewName(ViewConst.MAIN_LAYOUT);
view.addObject("view","catalog");
return view;
but in front (thymeleaf) i dont know how to get the values. 但是在前面(百里香叶),我不知道如何获得这些价值。 my code is the below:
我的代码如下:
<div th:each="product :${products}">
<h2 th:text="${product}"></h2>
</div>
</div>
but i don't know what put after the name of the variable. 但是我不知道变量名后面放了什么。 i already tried these ways: ${product.name}, ${product['name']}, ${product[0]} but none of them works.
我已经尝试过以下方法:$ {product.name},$ {product ['name']},$ {product [0]},但是它们都不起作用。
if i put only this ${product} it returns me in this format each value 如果我只输入这个$ {product},它将以这种格式返回每个值
[39, Moto KTM DUKE, /images/products/product39/m_39_0.jpg]
Based on what you replied with, I think these may work: 根据您的答复,我认为这些可能有效:
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>
You could also possibly use toArray() as well, though I'm not entirely sure how that would turn out: 您也可以使用toArray(),尽管我不完全确定结果如何:
<div th:each="product :${products}" th:with="data=${product.toArray()}">
<h2 th:text="${data[0]}" />
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.