目前mybatis我所知道的有两种情况,一种是在控制层中控制参数,加上‘%’,如下:
在xml文件里控制:
另一种方法:String date = request.getParameter("date");//接收前台传来的日期参数
变成:String searchText = "%" + text + "%";
或String searchText = new StringBuilder("%").append(text).append("%").toString();
在xml文件里控制:
select *
from t_pro p
where p.pro_date like concat(concat('%',#{date}),'%')