模糊查詢input框檢索

1.userBar.html
html

<li> <form  action="checksGoods" th:object="${goodsForm}" method="post">java

 <input name="commodityName" type="text"/><button type="submit" name="search">檢索                                        </button>web

</form>  </li>sql

2.GoodsController,javasession

 @RequestMapping(value = "checksGoods", method = RequestMethod.POST)app

    public String initGoodsRelate(Model model, HttpSession session, GoodsForm goodsForm, Device device) {ide

    List<GoodsForm> result = goodsService.searchGoodsListRelate(goodsForm);post

    model.addAttribute("list", result);  ui

    CartForm cartForm = new CartForm();spa

    model.addAttribute("cartList", cartService.searchCartList(cartForm));

    return "shop/index";

    }

4Goodsqlmap.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>

3.GoodsService.java

public List<GoodsForm> searchGoodsListRelate(GoodsForm frm) {


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

return result;

}

相關文章
相關標籤/搜索