ligerUI结合SSH分页

ligerUI结合SSH分页


1、jsp页面部分:


//表格		
$("#maingrid").ligerGrid({
			columns : [ {
				display : '序号',
				name : 'id',
				align : 'left',
				width : 100,
				minWidth : 60
			}, {
				display : '标题',
				name : 'title',
				minWidth : 120
			}, {
				display : '类型',
				name : 'type',
				minWidth : 120
			}, {
				display : '内容',
				name : 'content',
				minWidth : 140
			}, {
				display : '时间',
				name : 'addTime'
			}],
			dataAction : 'server',
			// 指定获取数据的url 
			url:'cellphone_refreshthing.action',
			sortName : 'id',
			width : '100%',
			height : '100%',
			pageSize : 2,
			usePager:true,
			rownumbers : true,
			checkbox : true,
			//应用灰色表头
			cssClass : 'l-grid-gray',
			heightDiff : -6
		});


2 、Controller层


// 后台获取数据
		List refreshThings=cellphoneService.getRefreshThings(pagesize, (page-1)*pagesize);
		Map map=new HashMap();
		// map中必须包含 Rows和Total属性
		map.put("Rows", refreshThings);
		// 在这,为Total指定数据共有6行,当然,实际情况是需要去数据库获取的,在这只是为了简化
		map.put("Total", 6);
		
		// 在这,利用了 google的gson api,方便把java对象转换成json数据  
		Gson gson=new Gson();
		String out=gson.toJson(map);
		
		System.out.println(out);
		HttpServletResponse response = ServletActionContext.getResponse();
		// 指定返回数据的格式为json  
		response.setContentType("application/json;charset=UTF-8");
		PrintWriter printWriter = response.getWriter();
		printWriter.print(out);
		printWriter.flush();
		printWriter.close();




你可能感兴趣的:(javascript,java,json,JSON,Json)