-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
11.29 MyBatis分页插件PageHelper的使用 #63
Comments
1.17遇到的一个巨坑:
tsaimn commented on 9 Mar 2018: abel533 commented on 12 Mar 2018: |
SpringBoot整合通用Mapper以及Pagehelper分页插件 |
/**
* 为了简单只有数据访问层,
* 写测试类测试
* 这里只用到了查询的方法,mapper提供
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class MapperTest {
@Resource
private StudentMapper studentMapper;
@Test
public void test1() {
//不分页查询
List<Student> lis1 = studentMapper.selectAll();
for (Student stu : lis1) {
System.out.println(stu);
}
System.out.println("-------------------------------------------------------------------");
System.out.println("-------------------------------------------------------------------");
//分页查询,显示第一页,每页五条
PageHelper.startPage(1,5);
List<Student> lis2 = studentMapper.selectAll();
for (Student stu : lis2) {
System.out.println(stu);
}
System.out.println("-------------------------------------------------------------------");
System.out.println("-------------------------------------------------------------------");
//分页查询,显示第一页,每页五条,按id降序
PageHelper.startPage(1,5,"stu_id desc");
List<Student> lis3 = studentMapper.selectAll();
for (Student stu : lis3) {
System.out.println(stu);
}
System.out.println("-------------------------------------------------------------------");
System.out.println("-------------------------------------------------------------------");
//分页查询,显示第一页,每页五条,按id降序
PageHelper.startPage(1,5,"stu_id desc");
Student student = new Student();
student.setName("二班张三");
List<Student> lis4 = studentMapper.select(student);
for (Student stu : lis4) {
System.out.println(stu);
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MyBatis分页插件PageHelper的使用
https://blog.csdn.net/eson_15/article/details/52270046
The text was updated successfully, but these errors were encountered: