模糊查询检索

1、在userBar.html

<li>

关键代码<form action="checkgoods" th:object="${goodsForm}" method="post">

<input name="commodityName" type="text"/>   关键代码:name里面名字

<button name="check" type="submit">检索</button>

</form></li>

2、在GoodsService.java

public List<GoodsForm> CheckGoodsUser(GoodsForm frm) {

    List<GoodsForm> result = queryDao.executeForObjectList("Goods.checkGoods", frm);

    return result;}

3、在GoodsController.java

  @RequestMapping(value = "/checkgoods", method = RequestMethod.POST)

    public String initLogin(GoodsForm goodsForm, Model model) {

   List<GoodsForm> result1= goodsService.CheckGoodsUser(goodsForm);

   model.addAttribute("list", result1);

     关键代码: CartForm cartForm = new CartForm();

     关键代码:    model.addAttribute("cartList", cartService.searchCartList(cartForm));

                              return "shop/index";

    }

4、在usersqlmap.xml

<select id="checkGoods"

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>





你可能感兴趣的:(模糊查询检索)