这个是我前台代码:function monitor_list(id) {
d = id;
$('#tbdata').datagrid({
    title:'监控点列表',
    fitColumns:true,
nowrap : true,
striped : true,
rownumbers:true,
url : 'bus_monitorListJOSN.action?bus.businessId='+ d + '&time=' + (new Date().getTime()),
sortName: 'monitorId2',
sortOrder: 'desc',
columns : [ [
{
field : 'monitorId',
width : 50,
checkbox : true
},
{
title : '业务ID',
field : 'businessId',
width : 80
},
{
title : '业务名称',
field : 'businessName',
width : 80
},
{
title : '监控ID',
field : 'monitorId2',
width : 50,
width : 80
},
{
title : '监控名称',
field : 'monitorName',
width : 150
},
{
title : '办理级别',
field : 'processsLevel',
width : 100
},
{
title : '是否提供报警',
field : 'status',
width : 80
},
{
field : 'opt',
title : '操作',
width : 150,
align : 'center',
formatter : function(value, rec, index) {
return "<a href='javascript:void(0);' onclick='toMonEdit(\""
+ rec.monitorId
+ "\");'>修改监控点</a>  <a href='javascript:void(0);' onclick='deletemon(\""
+ rec.monitorId
+ "\");'>删除监控点</a>";
}
} ] ],
pagination:true,
toolbar : [{
id : 'btnadd',
text : '新增',
iconCls : 'icon-add',
handler : function(){toMonitorAdd(d);}
},
'-',
{
text : '删除选中',
iconCls : 'icon-cut',
handler : toMonitorDel
} ]
});
}
这是我后台代码:action代码:public String monitorListJOSN() {
JSONObject json = null;
int page = Integer.parseInt(request.getParameter("page"));
int row = Integer.parseInt(request.getParameter("rows"));
try {
List<Object[]> monitor = buisnessService.findMonitor(bus,page,row);
Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("total", monitor.size());
List<Object> array = new ArrayList<Object>();
for (Object[] m : monitor) {
MrBusiness b = (MrBusiness) m[0];
MrMonitor n = (MrMonitor) m[1];
Map<String, Object> bean = new HashMap<String, Object>();
bean.put("businessId", n.getBusinessId());
bean.put("businessName", b.getBusinessName());
bean.put("monitorId", n.getMonitorId());
bean.put("monitorId2", n.getMonitorId());
bean.put("monitorName", n.getMonitorName());
bean.put("processsLevel", (n.getProcesssLevel()==0?"立即处理":"延后处理"));
bean.put("status", (n.getStatus()==0?"开启报警":"暂停报警"));
array.add(bean);
}
jsonMap.put("rows", array);
json = JSONObject.fromObject(jsonMap);
} catch (Exception e) {
new ServiceException("【控制层异常提示】:monitorListJOSN()");
e.printStackTrace();
}
this.jsonData = json.toString();
log.info("测试monitorListJOSN()返回josn数据:" + jsonData);
return Action.SUCCESS;
}
service代码:public List<Object[]> findMonitor(MrBusiness bus,int page,int rows) {
List<Object[]> list = null;
SessionFactory sf = getHibernateTemplate().getSessionFactory();
Session session = sf.openSession();
try {
session.beginTransaction();
if (bus != null && bus.getBusinessId() != null) {
String hql = "from MrBusiness m,MrMonitor mo where m.businessId = ? and mo.businessId=m.businessId";
list = session.createQuery(hql).setFirstResult((page-1)*rows).setMaxResults(rows).list();
}
log.info("测试 findMonitor(MrBusiness bus) 返回集合长度:" + list.size());
session.getTransaction().commit();
} catch (Exception e) {
new ServiceException("【业务层异常提示】:findMonitor(MrBusiness bus)");
e.printStackTrace();
}finally{
session.close();
sf.close();
}
return list;
}
大虾们,帮小弟我提提建议。