基于Jquery实现表格动态分页实现代码_jquery
程序员文章站
2022-04-12 22:31:49
...
当页面点击分页图标时,程序会自动去后台获取对应页数的记录。
关键代码如下:
需要引入的css和js文件有:
其中jsp页面代码如下:
html页面代码如下:
LOADING....
后台action中代码如下:
//分页获取用户信息
public void listUser2(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
RequestTool tool = new RequestTool(request);
Integer pageSize = tool.getIntParameter("pageSize");
Integer pageIndex = tool.getIntParameter("pageIndex");
ResultPage res = serviceSmUserImpl.findAllSmUsers(pageIndex, pageSize);
List smUserList = (List)res.getResult();
JSONArray array = new JSONArray();
JSONObject object ;
for(SmUser user:smUserList){
object = new JSONObject();
object.put("userId", user.getUserId());
object.put("userName",user.getUserName());
object.put("depId", user.getOrganCode());
object.put("createTime", user.getCreateTime());
object.put("creator", user.getCreator());
object.put("menusId", user.getMenusId());
object.put("isValid", (user.getValid().equals("1")?"有效":"无效"));
array.add(object);
}
AjaxTool.returnAjaxResponse(response, array.toJSONString());
}
//获取总的记录数和总页数
public void getPageCount(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
RequestTool tool = new RequestTool(request);
int pageSize = tool.getIntParameter("pageSize");
List pojos = serviceSmUserImpl.findAll();
int pageCount = pojos.size()% pageSize > 0 ? (pojos.size()/ pageSize+1):(pojos.size()/ pageSize);
JSONArray array = new JSONArray();
JSONObject object = new JSONObject();
object.put("pageCount", pageCount);
object.put("totalCount", pojos.size());
array.add(object);
AjaxTool.returnAjaxResponse(response,array.toJSONString());
}
文件打包下载
关键代码如下:
需要引入的css和js文件有:
复制代码 代码如下:
其中jsp页面代码如下:
复制代码 代码如下:
html页面代码如下:
复制代码 代码如下:
用户ID | 用户名称 | 所在科室 | 创建时间 | 创建人 | 菜单集名称 | 是否有效 |
---|---|---|---|---|---|---|
| | | | | | |
LOADING....
| | | | | | | |
后台action中代码如下:
复制代码 代码如下:
//分页获取用户信息
public void listUser2(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
RequestTool tool = new RequestTool(request);
Integer pageSize = tool.getIntParameter("pageSize");
Integer pageIndex = tool.getIntParameter("pageIndex");
ResultPage res = serviceSmUserImpl.findAllSmUsers(pageIndex, pageSize);
List
JSONArray array = new JSONArray();
JSONObject object ;
for(SmUser user:smUserList){
object = new JSONObject();
object.put("userId", user.getUserId());
object.put("userName",user.getUserName());
object.put("depId", user.getOrganCode());
object.put("createTime", user.getCreateTime());
object.put("creator", user.getCreator());
object.put("menusId", user.getMenusId());
object.put("isValid", (user.getValid().equals("1")?"有效":"无效"));
array.add(object);
}
AjaxTool.returnAjaxResponse(response, array.toJSONString());
}
//获取总的记录数和总页数
public void getPageCount(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
RequestTool tool = new RequestTool(request);
int pageSize = tool.getIntParameter("pageSize");
List
int pageCount = pojos.size()% pageSize > 0 ? (pojos.size()/ pageSize+1):(pojos.size()/ pageSize);
JSONArray array = new JSONArray();
JSONObject object = new JSONObject();
object.put("pageCount", pageCount);
object.put("totalCount", pojos.size());
array.add(object);
AjaxTool.returnAjaxResponse(response,array.toJSONString());
}
文件打包下载
上一篇: 关于HTML表格的详细介绍
下一篇: php RSS格式问题