easyui分页时,总页数出错
错误出现
MyBatis用easyui写后台分页代码时,出现翻页后显示总页数错误


代码如下
可能原因在于后台mappers.xml里的sql语句错误
<select id="getProductTotal" parameterType="Map" resultType="Long">
select count(*) from t_product
<where>
<if test="name!=null and name!=''">
and name like #{name}
</if>
</where>
<if test="start!=null and size!=null">
limit #{start},#{size}
</if>
</select>
去掉limit语句
<select id="getProductTotal" parameterType="Map" resultType="Long">
select count(*) from t_product
<where>
<if test="name!=null and name!=''">
and name like #{name}
</if>
</where>
</select>
controller的代码如下
@RequestMapping("/list")
public String list(@RequestParam(value="page",required=false)String page,@RequestParam(value="rows",required=false)String rows,Product product,HttpServletResponse response)throws Exception{
PageBean pageBean = new PageBean(Integer.parseInt(page),Integer.parseInt(rows));
Map<String,Object> map = new HashMap<String,Object>();
map.put("name", StringUtil.formatLike(product.getName()));
map.put("start", pageBean.getStart());
map.put("size", pageBean.getPageSize());
List<Product> productList = productService.productList(map);
Long total = productService.getProductTotal(map);
JSONObject result=new JSONObject();
JsonConfig jsonConfig=new JsonConfig();
jsonConfig.setExcludes(new String[]{"orderProductList"});
jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd"));
jsonConfig.registerJsonValueProcessor(ProductBigType.class,new ObjectJsonValueProcessor(new String[]{"id","name"}, ProductBigType.class));
jsonConfig.registerJsonValueProcessor(ProductSmallType.class,new ObjectJsonValueProcessor(new String[]{"id","name"}, ProductSmallType.class));
JSONArray jsonArray=JSONArray.fromObject(productList,jsonConfig);
result.put("rows", jsonArray);
result.put("total", total);
ResponseUtil.write(response, result);
return null;
}
改变后
因为前台easyui传入的数据start在变,变化前的sql语句为
SELECT COUNT(*) FROM t_product LIMIT 0,10
可以查询出总记录数
但start变化后
SELECT COUNT(*) FROM t_user LIMIT 10,10
无法查询出总记录数,所以导致出错!
easyui分页时,总页数出错的更多相关文章
- GridView自带分页 1总页数 首页 下一页 上一页 尾页 X 页 go 实现方法 .
在前台GRIDVIEW中添加如下代码 <PagerTemplate> <table> <tr> <td style="text-align: rig ...
- mvc自定义分页(加页数的)(转)
1.引言 在MVC开发中我们经常会对数据进行分页的展示.通过分页我们可以从服务端获取指定的数据来进行展示.这样既节约了数据库查询的时间也节约了网络传输的数据量.在MVC开发中使用的比较多的应该是MVC ...
- C# 返回分页查询的总页数
/// <summary> /// 返回分页查询操作的的总页数 /// </summary> /// <param name="count">总 ...
- word中怎样设置页码包含总页数
一个同事做毕业论文,论文是Word格式,1-2页是封面和目录,不需要页码,第3-10页是论文内容,需要从第1页开始显示,并显示论文内容的总页数8 页.具体为页脚处显示“第*页共*页”.他让我帮忙设置一 ...
- word2010页脚页码的总页数修改方法
3很多时候做WORD文档时,首页和尾页通常是做为封面与封底的是不做页码统计的. 这时候就需要总页面上减去首页和尾页的数量.以下为修改总页数方法 1.打开WORD文档设置页眉页脚,页脚设置页码, 2.设 ...
- 使用CyclicBarrier+线程池,按总页数分批次开多线程执行逻辑
通过CyclicBarrier+线程池的方式,同步的方式分页分批次并发高效处理逻辑,将总页数分成多个批次并发执行每页逻辑,每个批次处理DO_MAX_SIZE个页,每个批次等待DO_MAX_SIZE个页 ...
- js计算总页数
前端js取余是a%b 取除数parseInt(a / b) /** * 总页数@param(总条数,每页总条数) */ function pageTotal(rowCount, pageSize) { ...
- sql计算总页数
1 计算总页数方法: public int getTotalCount() { Statement stmt = null; //提交SQL语句对象stmt Resu ...
- js 计算总页数的最高效方式
js 计算总页数的最高效方式 /** * [getTotalPageNum 获取页码总数] * @param {[type]} totalRecord [总记录] * @param {[type]} ...
随机推荐
- makeObjectsPerformSelector用法
亲测 makeObjectsPerformSelector 的用法. - (void)makeObjectsPerformSelector:(SEL)aSelector NS_SWIFT_UNAVAI ...
- Git学习——把文件推送到远程仓库
本地仓库与GitHub仓库关联 git remote add origin git@github.com:<github账户名>/<github的仓库名>.git 把本地库的所 ...
- sram bist scripts
主要三个script: mbist_run: call mbistarchitect tool run.do:run bist flow bist setup => bist mode(bis ...
- '>>' should be '> >' within a nested template argument list
在编译关于opencv相机标定的工程的时候出现了这个问题 vector<vector<Point3f>> objectPoints; error: 'objectPoint ...
- Experimental considerations
先知 重金属颗粒与气孔大小 气孔位置.密度与开合时间 角质层厚度 意外 叶子第二天掉落 样本没有放冰箱 高光谱仪器损坏 天气下雨/雪 仪器预约 楼顶/实验室门卡提前一天预约 光合仪提前一天预约 ASD ...
- Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站
完整Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站 第一.安装和配置Apache Web服务器 运行升级命令来确保我们的系统组件各方面都是最新的. apt-get upd ...
- unittest跳过测试和预期失败
在运行测试时,有时需要直接跳过某些测试用例,或者当用例符合某个条件时跳过测试,又或者直接将测试用例设置为失败.unittest提供了这些需求的装饰器. unittest.skip(reason) 无条 ...
- 【工具】Homebrew的安装及使用
Homebrew官网:http://brew.sh/index_zh-cn.html Homebrew是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件,相当于linux下的a ...
- OSPF 提升 三 type of Areas
ospf ccnp 三 上图中 rip域中的不连续的100条路由 在a1中导致LSDB太大 在保证网段的可达性的前提下 尽可能减少区域内路由器的lsdb 可以将a1设置 ...
- Leetcode 363.矩形区域不超过k的最大数值和
矩形区域不超过k的最大数值和 给定一个非空二维矩阵 matrix 和一个整数 k,找到这个矩阵内部不大于 k 的最大矩形和. 示例: 输入: matrix = [[1,0,1],[0,-2,3]], ...