标签:
搜索框
userBar
<form action="serch" th:object="${goodsFrom}" method="post"> <li> <span><input name="commodityName" type="text" /></span> <span><button type="submit" name="sousuo">搜索</button></span> </li> </form>
GoodsController
@RequestMapping(value = "/serch", method = RequestMethod.POST) public String delete(GoodsForm goodsForm, Model model) { List<GoodsForm> rescult = goodsService.serchGoodsList(goodsForm); model.addAttribute("list", rescult); CartForm cartForm = new CartForm(); model.addAttribute("cartList", cartService.searchCartList(cartForm)); return "shop/index"; }
GoodsService
public List<GoodsForm> serchGoodsList(GoodsForm frm) { List<GoodsForm> result = queryDao.executeForObjectList("Goods.selectList", frm); return result; }
GoodsSqlMap
<select id="selectList" parameterClass="cn.agriculture.web.form.GoodsForm" resultClass="cn.agriculture.web.form.GoodsForm"> SELECT commodity.commodity_id as commodityId, commodity.type as type, 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>
标签:
原文地址:http://my.oschina.net/u/2411768/blog/482346