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();
    }

 

posted @ 2020-03-15 11:43  白熊啊  阅读(252)  评论(0编辑  收藏  举报