题记部分
(1)mapper类
List<User> getUserLike(String value);
(2)mapper.xml
<!-- 写法1 -->
<select id="getUserLike" resultType="com.harley.pojo.User">
select * from user where name like #{value}
</select>
<!-- 写法2 -->
<select id="getUserLike" resultType="com.harley.pojo.User">
select * from user where name like '%${value}%'
</select>
(3)测试类
代码执行的时候使用通配符
%keyword%
// 写法1
@Test
public void getUserLike(){
List<User> userList = userMapper.getUserLike("%日%");
for (User user : userList) {
System.out.println(user.toString());
}
}
// 写法2
@Test
public void getUserLike(){
List<User> userList = userMapper.getUserLike("日");
for (User user : userList) {
System.out.println(user.toString());
}
}
— 业精于勤荒于嬉,行成于思毁于随 —
标签:07,List,System,value,查询,userList,user,mybatis,getUserLike From: https://www.cnblogs.com/houhuilinblogs/p/18233126