easyui分页查询为什么会有下拉框_easyui-分页功能详解

我们现在后台是SSI,前台用的是jquery easyUi

easyui的Datagrid分页原理:

通过pagination:true,属性来指定easyui的分页功能,当前端页面会通过ajax发送分页显示请求时,会向后台传递两个参数,page和rows,在struts2的action中通过属性驱动可以获取这两个值,最后在dao层通过ssi的分页查询返回map,查处符合分页要求的结果。

前端页面通过firebug抓取传参图:

从捕捉的前台页面来看,前台传递到后台的两个参数是page和rows;page是指当前页码,rows是页面分页显示的大小。

在前端html页面,easyui的分页功能如何实现:

在easyui中,通过ajax访问后台getAmsSysPriceFormulaJson.action进行参数传递,在后台进行ibatis分页查询并返回数据:

/**

* 根据输入的条件分页查询结果,结果在resultMap中

* 1、组织一个条件的map,map中必须要有用于分页的rows和page,还有条件的实体bean 2、根据条件的实体bean查询结果的总记录条数

* 3、根据前面组织map条件给服务类查询分页的结果,结果为要显示的记录

* 4、把结果放到resultMap中,前台把结果通过struts转换成json数据使用 5、系统返回success通知struts操作成功

*

* @return 标志字符串

*/

public String getAmsSysPriceFormulaJson() {

Map map = new HashMap();// 装载分页函数需要的参数,里边包含每页多少条,第几页,查询条件

if (this.rows == 0) {

map.put("rows", 10); // 放入每页条数

} else {

map.put("rows", this.rows); // 放入每页条数

}

if (this.page == 0) {

map.put("page", 1); // 放入当前页码

} else {

map.put("page", this.page); // 放入当前页码

}

System.out.println("rows:" + rows + " page:" + page);

// 如果没有指定排序,则给一个默认的值

if (this.sort == null) {

this.setSort("CHANNEL_NAME,START_TIME");

this.setOrder("ASC");

}

map.put("sort", this.sort);

map.put("order", this.order);

map.put("amsPriceFormula", amsPriceFormula);

searchAmsSysPriceFormulaList = amsSysPriceFormulaService

.selectSysPriceFormula(map);

for (int i = 0; i < searchAmsSysPriceFormulaList.size(); i++) {

AmsSysPriceFormula amsPriceFormula = searchAmsSysPriceFormulaList

.get(i);

if (amsPriceFormula.getStateCode() != null) {

if (amsPriceFormula.getStateCode() == 1) {

amsPriceFormula.setStateCodeName("有效");

} else if (amsPriceFormula.getStateCode() == 2) {

amsPriceFormula.setStateCodeName("无效");

} else {

amsPriceFormula.setStateCodeName(" ");

}

if (amsPriceFormula.getBaseLength() == null) {

amsPriceFormula.setBaseLength(0);

}

amsPriceFormula.setRateName("$"

+ amsPriceFormula.getBaseLength() + "*"

+ amsPriceFormula.getRate());

}

amsPriceFormula.setRateName("$" + amsPriceFormula.getBaseLength()

+ "*" + amsPriceFormula.getRate()

+ amsPriceFormula.getStateCode());

System.out.print(amsPriceFormula.getStateCodeName());

searchAmsSysPriceFormulaList.remove(i);

searchAmsSysPriceFormulaList.add(i, amsPriceFormula);

}

int total = amsSysPriceFormulaService

.selectSysPriceFormulaCount(amsPriceFormula);// 获取符合条件的数据总数量

System.out.println("总数量" + total);

resultMap.put("total", total);

resultMap.put("rows", searchAmsSysPriceFormulaList);

if (resultMap != null) {

return "success";

} else {

this.message = "1";

return "error";

}

}

ssi框架可以使用ibitis的自带分页查询功能:

PaginatedList paginatedList=sqlMap.queryForPaginatedList(statementName, parameterObject, pageSize);其中statementName就是你xml里配置的statement id,parameterObject就是传递的参数,pageSize就是返回的一页多少个。

iBatis默认的分页是采用游标滚动的方式来实现的,这种方式在大数据量的情况下便会OOM了,因此一般都采用手写分页SQL语句使用数据库物理分页方式实现

注意 :ibatis里边拼写SQL语句的一些规则符号的使用区别

1.#是把传入的数据当作字符串,如#field#传入的是id,则sql语句生成是这样,order by "id",这当然会报错..

2.$传入的数据直接生成在sql里,如#field#传入的是id,则sql语句生成是这样,order by id, 这就对了.

3.#方式能够很大程度防止sql注入.

4.$方式无法防止sql注入.

5.$方式一般用于传入数据库对象.例如传入表名.

oracle的三层嵌套查询:

//外面的是分页过滤

Select * from(

//通过子查询给定行号

Select rownum r ,*from( select * from 表 orderby 字段 //子查询实现排序

)where A //条件查询,上限

)where B  //条件查询,下限

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值