jsp页面如下:
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@include file="/commons/include/html_doctype.html" %> <%@taglib prefix="f" uri="http://www.jee-soft.cn/functions" %><html><head> <title>注入信息提示</title> <%-- <%@include file="/commons/include/get.jsp" %> --%> <f:link href="Aqua/css/ligerui-all.css"></f:link> <script type="text/javascript" src="${ctx}/oms/js/jquery/jquery.js"></script> <script type="text/javascript" src="${ctx}/oms/js/lg/ligerui.min.js"></script> <script type="text/javascript" src="${ctx}/oms/js/lg/plugins/ligerGrid.js"></script><script type="text/javascript">
var columns =
[ { display: '登录时间', name: 'dlsj'}, { display: '登录人', name: 'dlr' }, { display: '登录IP', name: 'dlIP' } ];$(function() {
$("#maingrid").ligerGrid({ width:1000, dataAction:'server', columns:columns, // data:jsonObj, url:"${ctx}/oms/appCrd/appCrd/zdhzbdatecount/zdhzbdatecount.ht", //向后台提交的数据 根据systemId来进行排序 sortName: 'dlsj', //向后台提交的数据 排序方向为升序 sortorder:'asc', //后台提交的数据 每页显示的记录数 pageSize: 10, usePager:true, //数据书否分页,默认为true pageSizeOptions:[10,50,100],//可指定每页页面大小 onSelectRow: function (rowdata, rowindex, rowobj) { //选中行事件。。。 //alert($(rowobj).val()); }, checkbox: false, height: '100%', rownumbers: true });});
</script></head><body> <div id="maingrid"></div> </body></html>
java代码:
@RequestMapping("zdhzbdatecount")
public @ResponseBody JSONObject zdhzbdatecount(HttpServletRequest request, HttpServletResponse response) throws Exception { List<Zdhzbdatecount> list = new ArrayList<Zdhzbdatecount>();SysAuditService sysAuditService = AppUtil.getBean(SysAuditService.class);
List<SysAudit> listSys = sysAuditService.getAll(new QueryFilter(request, "sysAuditItem"));for (SysAudit e : listSys) {
Zdhzbdatecount entity = new Zdhzbdatecount(); entity.setDlIP(e.getFromIp()); if(e.getExecutor()==null){ entity.setDlr("无"); }else { entity.setDlr(e.getExecutor()); } entity.setDlsj(e.getExeTime()); list.add(entity); } String jsonstring = JSON.toJSONString(list); JSONObject object = new JSONObject(); JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd"; String format = JSON.toJSONString(list, SerializerFeature.WriteDateUseDateFormat);// object.put("Rows", JSON.parseArray(jsonstring)); object.put("Rows", JSON.parseArray(format)); object.put("Total", list.size()); return object; }
---------------分页失败了,但不深究---------------------