There are many ways in this site. https://code.google.com/p/mybatis/issues/detail?id=85
You have experimented with the following methods.
1. Add the percent to the parameter directly
Param.setusername ("%cd%");
Param.setpassword ("%11%");
<select id= "selectpersons" resulttype= "person" parametertype= "person" >select id,sex,age,username, Password from person where true <if test= "Username!=null" > and username like #{username}</if><if test= "pas Sword!=null ">and password like #{password}</if></select>
2. Bind tag
<select id= "selectpersons" resulttype= "person" parametertype= "person" > <bind name= "pattern" value= "'% ' + _parameter.username + '% ' "/> select Id,sex,age,username,password from who where username like #{ Pattern}</select>
3. CONCAT
where username like concat (concat ('% ', #{username}), '% ')
SQL fuzzy query for "Mybatis" Mybatis