mybatis之模糊查询
1.编写接口
List<User> getUserLike(String value);
2.编写映射文件
<select id="getUserLike" resultType="com.kuang.pojo.User">
SELECT * FROM mybatis.user WHERE name LIKE "%"#{value}"%"
</select>
3.编写实现类
@Test public void getUserLike(){ SqlSession sqlSession = MybatisUtils.getSqlSession(); UserMapper mapper = sqlSession.getMapper(UserMapper.class); List<User> userList = mapper.getUserLike("李"); for (User user : userList) { System.out.println(user); } sqlSession.close(); }