1. 参数中直接加入%%
代码如下 | 复制代码 |
param.setUsername("%CD%"); param.setPassword("%11%"); select id,sex,age,username,password from person wheretrue |
2. bind标签
代码如下 | 复制代码 |
select id,sex,age,username,password from person where username LIKE #{pattern} |
3. CONCAT
代码如下 | 复制代码 |
where username LIKE concat(concat('%',#{username}),'%') |