<form action="selectGoods" th:object="${goodsForm}" method="post">
<input type="text" class="inpt" placeholder="请输入关键字" name="commodityName"/>
<input type="submit" value="检索" class="btnS"/>
</form>
@RequestMapping(value = "selectGoods", method = RequestMethod.POST)
public String selectGoods(Model model,HttpSession session,GoodsForm goodsForm,Device device){
log.info("检索相关商品");
model.addAttribute("commodityType", goodsService.getType());
List<GoodsForm> list=goodsService.searchGoodsListrelative(goodsForm);
model.addAttribute("list",list);
model.addAttribute("orderTypeId", 1);
UVO uvo = (UVO)session.getAttribute("UVO");
if (uvo == null) {
uvo = new UVO();
session.setAttribute("UVO", uvo);
}
if(device.isNormal()) {
return "shop/list";
} else {
return "mobile/list";
}
}
<select id="selectGoodsListrelative"
parameterClass="cn.agriculture.web.form.GoodsForm"
resultClass="cn.agriculture.web.form.GoodsForm">
SELECT commodity.commodity_id as commodityId,
commodity.type as commodityTypeId,
supplier.supplier_name as supplierName,
brand.brand_name as brandName,
commodity.commodity_name as commodityName,
commodity.weight as weight,
commodity.is_gift as isGift,
commodity.specifications as specifications,
commodity.unit as unit,
commodity.benchmark_price as benchmarkPrice,
commodity.guide_price as guidePrice,
commodity.retail_price as retailPrice,
commodity.competition_level as competitionLevel,
commodity.note as note,
commodity.update_time as updateTime,
commodity.update_user as updateUser,
commodity.picture_id as pictureId,
stock.stock as stock
FROM commodity, supplier, brand, stock
WHERE commodity.commodity_id = stock.commodity_id
AND commodity.supplier_id = supplier.supplier_id
AND commodity.brand_id = brand.brand_id
AND commodity.commodity_name LIKE '%$commodityName$%'
</select>
<div>
<div class="col-sm-6 flipBox">
<h4 class="h5">共 <span th:text="${list.size()}"> 999 条记录</span> 条记录</h4>
</div>
</div>
<form action="addCart" th:object="${goodsForm}" method="post">
<ul class="goodsList cf">
<li class="col-md-2 col-sm-4 col-xs-6" th:each="goodsInfo,status:${list}">
<div class="cont">
<a th:href="@{initGoodsDetail(commodityId=${goodsInfo.commodityId})}"><img th:src="@{showImage(pictureId=${goodsInfo.pictureId})}" alt="" style="height:168px;width:168px;"/></a>
<h4 class="h5"><a th:href="@{initGoodsDetail(commodityId=${goodsInfo.commodityId})}"><p th:text="${goodsInfo.commodityName}">品美知糖道阿胶姜汤260g</p></a></h4>
<p class="num">库存:<span th:text="${goodsInfo.stock}">15</span>
每<span th:text="${#strings.concat(goodsInfo.unit).concat(goodsInfo.specifications)}">袋15kg</span>
</p>
<p class="cf">
<span class="price yh">¥<span th:text="${goodsInfo.retailPrice}">15</span>元</span>
<a href="#" class="btnBuy" title="加入购物车"></a>
</p>
</div>
</li>
</ul>
</form>
</div>