模糊查询的实现步骤
在提前搭建好的环境下实现一个模糊查询的功能
1.接口编写
//模糊查询
List<User> getUserByLike(String vlaue);
2.配置文件的编写
<select id="getUserByLike" parameterType="String" resultType="com.lty.pojo.User">
select * from user where name like #{value};
</select>
3.测试的编写
@Test
public void getUserByLike(){
SqlSession session = MybatisUtils.getSession();
UserDao mapper = session.getMapper(UserDao.class);
List<User> user = mapper.getUserByLike("%萌%");
for (User user1 : user) {
System.out.println(user1);
}
}
4.执行结果