Home >Web Front-end >JS Tutorial >Implementation code for table dynamic paging based on Jquery_jquery

Implementation code for table dynamic paging based on Jquery_jquery

WBOY
WBOYOriginal
2016-05-16 18:05:45994browse

When the page clicks the paging icon, the program will automatically go to the background to obtain the record of the corresponding page number.
The key code is as follows:
The css and js files that need to be imported are:

Copy the code The code is as follows:



< script language="javascript" type="text/javascript" src="<%=basePath %>js/jquery.js">

where jsp page code As follows:
Copy code The code is as follows:



html page code is as follows:
Copy code The code is as follows:


























用户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 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());
}

文件打包下载
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn