-
page 对象可以自己创建,jpa,spring data 也提供了 ,其他两个没有提供
-
前台会传过来一个pageNo 当前页面,已知参数,需要后台自己查,总记录数,前台传过来的还有一个每页显示多少行, 这两个属性都可以在page中定义,当用户打开时,肯定是第一页,其他的几个参数都已可以用这三个参数给计算出来
-
hibernate 是 criteria.setFirstResult(firstResult).setMaxResults(maxResults);
-
jpa是 先创建一个PageRequest对象,然后在findAll(pageRequest);即可
-
mybatis是 自己定义一个接口,参数是map,自己写sql语句查,下面这个是其配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<sql id= "salesChanceQueryCondition" > WHERE status = #{status} < if test= "custName!=null" > AND cust_name LIKE #{custName} </ if > < if test= "title!=null" > AND title LIKE #{title} </ if > < if test= "contact!=null" > AND contact LIKE #{contact} </ if > </sql> <select id= "getPagedPlanContent" parameterType= "map" resultType= "com.atuigu.crm.entity.SalesChance" > SELECT * FROM ( SELECT rownum rn, id,cust_name,title,contact,contact_tel,create_date , status FROM sales_chances <include refid= "salesPlanedChanceQueryCondition" /> ) <![CDATA[ WHERE rn >= #{fromIndex} AND rn < #{endIndex} ]]> </select> |