Header.html
<form action= "Selectgoods" th:object= "${goodsform}" method= "POST" ><input type= "text" class= "INPT" Placeholder= "Please enter the keyword" name= "commodityname"/><input type= "Submit" value= "Retrieve" class= "Btns"/></form>
Goodscontroller.java
@RequestMapping (value = "Selectgoods", method = requestmethod.post) public string selectgoods (Model model,httpsession session,goodsform goodsform,device device) { log.info ("Search related items"); 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", &NBSP;UVO); } cartform cartform = new Cartform (); caRtform.setguestid (Uvo.getguestid ()); model.addattribute ("Cartlist", Cartservice.searchcartlist (Cartform)); model.addattribute ("GoodsForm", goodsForm); if (Device.isnormal ()) { return "Shop/list"; } else { return "Mobile/list"; } }
Goodsservice.java
Public list<goodsform> searchgoodslistrelative (goodsform frm) {list<goodsform> result = Querydao.executeforobjectlist ("goods.selectgoodslistrelative", frm); return result;}
Goodssqlmap.xml
<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 stockfrom commodity, supplier, brand, stockwhere commodity.commodity_id = stock.commodity_idand commodity.supplier_id = supplier.supplier_idAND commodity.brand_id = brand.brand_idAND commodity.commodity_name like '% $commodityName $% ' </select>
Search for "commodities"