问题描述
- springmvc+jqgrid绑定时报空指针
-
controller:@RequestMapping(value="/housesData")
public @ResponseBody JqGridPage showHousesData(JqGridPage jgp,SearchInfoVo vo){
try {
int count = housesInfoService.queryResultsCount(vo);
jgp.execute(count);
List list = housesInfoService.queryByPage(vo, jgp.getFirstResult(), jgp.getMaxResults());
jgp.setData(list);
} catch (Exception e) {
e.printStackTrace();
}
return jgp;
}页面脚本:
$("#u0_img").jqGrid({
url: "/tenant_love/back/housesData",
type: "POST",
pgbuttons:true ,
datatype: "json",
mtype : "POST" ,
colNames: [
"获取日期","标题","房源类型"
],
colModel: [
{
name: "createdTime",
index: "createdTime",
sortable:false,
width : 200,
formatter:"date",
formatoptions: {srcformat:'Y-m-d',newformat:'Y-m-d'}
}
,{
name: "housesName",
index: "housesName",
sortable:false,
width : 600,
},{
name:"needType",
index:"needType",
sortable:false,
width : 200
}
],
jsonReader: {
root: "data",
repeatitems: false
},
rowNum: 10,
rownumbers:true,
height: 360,
width: $("#u0_img").parent().innerWidth()-4,
scrollOffset: 0,
forceFit: true,
pager: "#u0pager",
viewrecords: true,
beforeRequest: housesQuery
});function housesQuery() { var postData = $("#u0_img").jqGrid("getGridParam", "postData"); postData["page"]=1; }
工具类:
public class JqGridPage {
/** * how many rows we want to have into the grid */ private Integer rows; /** * the requested page */ private Integer page; /** * index row - i.e. user click to sort */ private String sidx; /** * the direction */ private String sord; /** * total pages */ private Integer total; /** * records count */ private Integer records; /** * data rows */ private ArrayList data; private int firstResult; private int maxResults; private int result; private String houseSumPrice; public void execute(int count) { records = count; total = records / rows; if (records % rows != 0) total += 1; firstResult = page * rows - rows; maxResults = rows; }
//get,set方法省略
请大神帮我看下,以上代码出了什么问题,运行时总是报空指针异常,说是JqGridPage的属性未赋值成功,也就是未绑定成功?