Thymeleaf - 将对象传递到另一个字段而不重定向
Thymeleaf - passing object to another field without redirecting
我正在尝试在用户单击 this a href 时从控制器获取此对象列表的对象 (p) :
<li th:each="p : ${products}">
<figure>
<a class="aa-product-img" href="#"><img th:src="${p.picture1min}" style="width: 250px; height: 300px;"></a>
<a class="aa-add-card-btn"href="#"><span class="fa fa-shopping-cart"></span>Add To Cart</a>
<figcaption>
<h4 class="aa-product-title"><a href="#" th:text="${p.nome}">Polo T-Shirt</a></h4>
<span class="aa-product-price" th:text="${'R$: ' + #numbers.formatDecimal(p.newPrice, 0, 'POINT', 2, 'COMMA')}"></span><span th:if="${p.isVaryingColor()}" class="aa-product-price"><del th:text="${'R$: ' + #numbers.formatDecimal(p.oldPrice, 0, 'POINT', 2, 'COMMA')}"></del></span>
</figcaption>
</figure>
<div class="aa-product-hvr-content">
<a href="#" data-toggle="tooltip" data-placement="top" title="Add to Cart"><span class="fa fa-heart-o"></span></a>
<a href="#" data-toggle2="tooltip" data-placement="top" title="Espiar" data-toggle="modal" data-target="#quick-view-modal"><span class="fa fa-search"></span></a>
</div>
<!-- product badge -->
<span class="aa-badge aa-sale" href="#" th:if="${p.isVaryingColor()}">Promotion!</span>
</li>
并发送到同一页面上的 Quick view product(弹出窗口 div)
<!-- Modal view content -->
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="aa-product-view-content">
<h3>T-Shirt</h3>
<div class="aa-price-block">
<span class="aa-product-view-price" th:text="${product.price}">.99</span>
<p class="aa-product-avilability">Avilability: <span>In stock</span></p>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officiis animi, veritatis quae repudiandae quod nulla porro quidem, itaque quis quaerat!</p>
<h4>Size</h4>
<div class="aa-prod-view-size">
<a href="#">S</a>
<a href="#">M</a>
<a href="#">L</a>
<a href="#">XL</a>
</div>
<div class="aa-prod-quantity">
<input type="text" value="1" th:value="${product.quantity}">
<p class="aa-prod-category">
Category: <a href="#">Polo T-Shirt</a>
</p>
</div>
<div class="aa-prod-view-bottom">
<a href="#" class="aa-add-to-cart-btn"><span class="fa fa-shopping-cart"></span>Add To Cart</a>
<a href="#" class="aa-add-to-cart-btn">View Details</a>
</div>
</div>
</div>
正在显示有关此对象(产品)的信息,但我不想重定向页面,也许有一种方法可以将此对象发送到控制器,搜索数据库并 return 快速查找产品模式查看而不重定向页面?
我使用 Ajax 解决了这个问题,当用户单击按钮时,ajax 将产品 ID 作为参数发送到控制器中的方法,并 returns 发送到 thymeleaft 页面ajax 更新这些字段
我正在尝试在用户单击 this a href 时从控制器获取此对象列表的对象 (p) :
<li th:each="p : ${products}">
<figure>
<a class="aa-product-img" href="#"><img th:src="${p.picture1min}" style="width: 250px; height: 300px;"></a>
<a class="aa-add-card-btn"href="#"><span class="fa fa-shopping-cart"></span>Add To Cart</a>
<figcaption>
<h4 class="aa-product-title"><a href="#" th:text="${p.nome}">Polo T-Shirt</a></h4>
<span class="aa-product-price" th:text="${'R$: ' + #numbers.formatDecimal(p.newPrice, 0, 'POINT', 2, 'COMMA')}"></span><span th:if="${p.isVaryingColor()}" class="aa-product-price"><del th:text="${'R$: ' + #numbers.formatDecimal(p.oldPrice, 0, 'POINT', 2, 'COMMA')}"></del></span>
</figcaption>
</figure>
<div class="aa-product-hvr-content">
<a href="#" data-toggle="tooltip" data-placement="top" title="Add to Cart"><span class="fa fa-heart-o"></span></a>
<a href="#" data-toggle2="tooltip" data-placement="top" title="Espiar" data-toggle="modal" data-target="#quick-view-modal"><span class="fa fa-search"></span></a>
</div>
<!-- product badge -->
<span class="aa-badge aa-sale" href="#" th:if="${p.isVaryingColor()}">Promotion!</span>
</li>
并发送到同一页面上的 Quick view product(弹出窗口 div)
<!-- Modal view content -->
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="aa-product-view-content">
<h3>T-Shirt</h3>
<div class="aa-price-block">
<span class="aa-product-view-price" th:text="${product.price}">.99</span>
<p class="aa-product-avilability">Avilability: <span>In stock</span></p>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officiis animi, veritatis quae repudiandae quod nulla porro quidem, itaque quis quaerat!</p>
<h4>Size</h4>
<div class="aa-prod-view-size">
<a href="#">S</a>
<a href="#">M</a>
<a href="#">L</a>
<a href="#">XL</a>
</div>
<div class="aa-prod-quantity">
<input type="text" value="1" th:value="${product.quantity}">
<p class="aa-prod-category">
Category: <a href="#">Polo T-Shirt</a>
</p>
</div>
<div class="aa-prod-view-bottom">
<a href="#" class="aa-add-to-cart-btn"><span class="fa fa-shopping-cart"></span>Add To Cart</a>
<a href="#" class="aa-add-to-cart-btn">View Details</a>
</div>
</div>
</div>
正在显示有关此对象(产品)的信息,但我不想重定向页面,也许有一种方法可以将此对象发送到控制器,搜索数据库并 return 快速查找产品模式查看而不重定向页面?
我使用 Ajax 解决了这个问题,当用户单击按钮时,ajax 将产品 ID 作为参数发送到控制器中的方法,并 returns 发送到 thymeleaft 页面ajax 更新这些字段