jfinal 分页查询 sql 关键字出现的一些小问题,请注意啦

一开始写成了这样:

Page<Market> markets = dao.paginate(pageNumber, 15, "select * ", "from market where cid=? and name like '%?%' order by id asc",cid,marketName);

发生这样的错误:

 java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).

改成这样:

Page<Market> markets = dao.paginate(pageNumber, 15, "select * ", "from market where cid=? and name like ? order by id asc",cid,"%"+marketName+"%");

结果:顺利解决!!!

评论区

JFinal

2017-04-05 13:23

经常有人不记得如何给 like 传参,感谢分享

jxestone

2017-04-05 13:50

@JFinal 应该的^.^

热门分享

扫码入社