我最近刚开始用小胖的gt-grid做表格,struts2,myeclipse, 数据库是oracle。
碰到问题是,后台分页,前台点下一页那个导航时,却从1页变到11页,然后是21,51,我觉得是我后台处理后传向前台的页码值,它当做字符了,所以相加变为11了,我贴出来,大家帮我看看是我哪里错了。
页面写的有点乱,大家耐心看看,感谢下,哪位高人有能用的struts2与gt-grid结合,后台的例子发给我,感激不尽!我是参考小胖的基础教程http://fins.javaeye.com/blog/215063 中做的,
public String getgtGrid() {
String result = "getgtGrid";
HttpServletRequest request = ServletActionContext.getRequest();
//获取从前台grid.query()方法传来的param参数
String equid=request.getParameter("equid");
String people=request.getParameter("people");
。(略参数)
  //获取前台传来的json字符串
String gtJson=request.getParameter("_gt_json");
JSONObject jsonObj = JSONObject.fromObject(gtJson);
  //获取前台的pageInfo中2个数据,pagesize页面大小和当前页pageNum
Map pageInfo = (Map)jsonObj.get("pageInfo");
int pageSize= Integer.parseInt(pageInfo.get("pageSize").toString());//*******(1)  
int pageNum= Integer.parseInt(pageInfo.get("pageNum").toString()); //********(2)
  //调用service、dao得到总记录数
  int tatalsize=equipService.findSize(condition);
  //通过页面传来的2个参数进行分页查询得到list
List<SysObject> innerEquipmentList = equipService.findEquipment(pageSize,pageNum);
//将总数传回页面
pageInfo.put("totalRowNum" , new Integer(tatalsize) );
  Map gtJsonOut=new HashMap();   
  gtJsonOut.put("pageInfo",pageInfo);   
  gtJsonOut.put("data",innerEquipmentList );
  String outData2 = JsonUtil.map2json(gtJsonOut) 
try {
// 设置传向前台的通信数据格式UTF-8
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
// 把数据传给给前台
PrintWriter out = ServletActionContext.getResponse().getWriter();
out.print(outData2);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
也不知道哪里错了,前台可以获得分页效果,我初步怀疑是我上边*****(1)(2)那两句话的问题
就是点下一页时页码乱了,但点前一页好好的 ,
再次求助高人给我一份能用的实例struts2+gt_grid+myeclipse