Two ways of fuzzy query in mybatis

can be added % in the test class or % in the SQL of the configuration file in two ways:
the first way is to add:
test class:

 public void findByName(){
        List<User> users = userDao.findByName("王");
        for (User user:users){
            System.out.println(user);
        }
    }

profile:

<selectid="findByName"parameterType="string"resultType="com.itheima.daomain.User">
            select * from user where username like '%${value}%';
 </select>

the second test class adds %
test class:

 public void findByName(){
       List<User> users = userDao.findByName("%王%");
        for (User user:users){
            System.out.println(user);
        }
    }

profile:

<selectid="findByName"parameterType="string"resultType="com.itheima.daomain.User">
        select * from user where username like #{username};
</select>

Read More: