一,获得sigma 发送的服务端的 _gt_json
request.getParameter("_gt_json")
{"recordType":"object","pageInfo":{"pageSize":10,"pageNum":1,"totalRowNum":-1,"totalPageNum":0,"startRowNum":1,"endRowNum":-1},...
二,利用json工具获得pageInfo的pageSize,pageNum(jackson)
ObjectMapper mapper = new ObjectMapper();
Map map=mapper.readValue(_gt_json,Map.class );
Map map2=(Map) map.get("pageInfo");
int pageNum=(Integer) map2.get("pageNum");
int pageSize=(Integer) map2.get("pageSize");
三,分页查询(mysql)
sql="SELECT * FROM auction_user LIMIT ?,?" // (pageNum-1)*pageSize,pageSize)
int totalRowNum= select count(1) from auction_user //
四,返回数据格式
{
pageInfo:{totalRowNum:17},
data : [{"userId":12,"username":"tian","userpass":"s","email":"a","mobile":"s"},......]
}
out.write("{ pageInfo:{totalRowNum:"+String.valueOf(totalRowNum)+"},");
out.write(" data : "+mapper.writeValueAsString(pageUser)+" }");