MyBatis可以使用selectList()方法来返回一个List对象。以下是一些示例代码:
selectList()方法返回List对象:<!-- 定义查询语句 --><select id="getUserList" resultType="User"> SELECT * FROM users</select>// 调用selectList()方法返回List对象List<User> userList = sqlSession.selectList("getUserList");在注解中使用@Select注解和List作为返回类型:@Select("SELECT * FROM users")List<User> getUserList();// 调用getUserList()方法返回List对象List<User> userList = userDao.getUserList();在这些示例中,User类是一个自定义的Java对象,用于表示数据库中的用户信息。根据需要,可以将resultType属性设置为自定义类的全限定名,或者在注解中直接指定返回类型为List。

