param.setBookName("%Java%");
param.setBookCounts("%10%");<select id="selectBook" resultType="book" parameterType="book">select * from book where true<if test="bookname!=null"> AND bookname LIKE #{bookname}</if><if test="bookcounts!=null">AND bookcounts LIKE #{bookcounts}</if></select>
bind标签
<select id="selectBook" resultType="book" parameterType="book"><bind name="bookName" value="'%' + _bookName.bookname + '%'" />select * from book
where bookname LIKE #{bookName}</select>
CONCAT
select * from book where bookname LIKE concat(concat('%',#{bookname}),'%')
参数中直接加入%% param.setBookName("%Java%"); param.setBookCounts("%10%");<select id="selectBook" resultType="book" parameterType="book"> select * from book where true <if test="username!=null"> AND bookname LIKE #{bookname}</if> .