@TestpublicvoidtestGetUserByUserName()throwsIOException{UserMapper userMapper = sqlSession.getMapper(UserMapper.class);List<User> userList = userMapper.getUserByUserName("张");for(User user : userList){System.out.println(user);}}
在UserMapper.java中添加对应的属性
List<User>getUserByUserName(String 张);
在UserMapper.xml中添加查询sql语句如下
<select id="getUserByUserName" parameterType="java.lang.String" resultType="cn.fpl1116.pojo.User">
select * from user where username like '%${value}%'
</select>
<select id="login" parameterType="cn.fpl1116.pojo.User" resultType="cn.fpl1116.pojo.User">
select * from user where username='${username}' and password='${password}'
</select>