Mapper
//根据条件查询信息
List selectSaleInfoByData(@Param("typename")String typename,@Param("productnum")String productnum,
@Param("productname")String productname,@Param("storename")String storename);
mapper.xml
select * from saleinfo
typename=#{typename}
and productnum=#{productnum}
and productname like '%'+#{productname}+'%'
and storename=#{storename}
controller
/**
* 根据条件查询信息
* @param typename
* @param productnum
* @param productname
* @param session
* @param request
* @return
*/
@RequestMapping(value="/selectSaleInfo.html",method=RequestMethod.GET)
public String selectSaleInfoByDatas(@RequestParam(value="typename",required=false)String typename,@RequestParam(value="productnum",required=false)String productnum,
@RequestParam(value="productname",required=false)String productname,HttpSession session){
Store store=(Store) session.getAttribute(Constants.USERINFO_SESSION);
String storename=store.getStorename();
System.out.println(typename);
System.out.println(productnum);
System.out.println(productname);
System.out.println("=========>"+storename);
List<SaleInfo> list1=saleInfoService.selectSaleInfoByData(typename, productnum, productname, storename);
session.setAttribute("saleinfodatalist", list1);
return "selectSaleInfo";
}
jsp
品类查询: 商品代码: 商品名称:控制台
- (39749 ms) - 2019-4-8 15:06:55DEBUG ==> Preparing: select * from saleinfo WHERE typename=? and productnum=? and productname like '%'+?+'%' and storename=?
- (39749 ms) - 2019-4-8 15:06:55DEBUG ==> Parameters: (String), 111413170(String), (String), 003石碣店(String)
- (39783 ms) - 2019-4-8 15:06:55DEBUG <== Total: 0
- (39784 ms) - 2019-4-8 15:06:55DEBUG Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@221de751]
- (39785 ms) - 2019-4-8 15:06:55DEBUG Returning JDBC Connection to DataSource 查不到结果