基于Jquery实现表格动态分页实现代码(2)


<body>
<div>
<div>
<br />
<table bgcolor="#CCCCCC" cellSpacing="1" cellpadding="1">
<tr>
<th>
用户ID</th>
<th>
用户名称</th>
<th>
所在科室</th>
<th>
创建时间</th>
<th>
创建人</th>
<th>
菜单集名称</th>
<th>
是否有效</th>
</tr>
<tr bgcolor="#F9FDFF">
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
<div>
LOADING....
</div>
<div >
<div>
<div>
<table>
<tr>
<td>
<select>
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</td>
<td>
<div />
</td>
<td>
<div />
</td>
<td>
</td>
<td>
<div />
</td>
<td>
<div />
</td>
<td>
</td>
<td>
<span></span>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div></div>
<input type="hidden" />
<input type="hidden" />
</body>


后台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<SmUser> smUserList = (List<SmUser>)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<POJO> 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());
}


文件打包下载

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdfwxd.html