Easyui-datagrid-pagination结合Struts2使用时不显示Total

问题:Easyui-datagrid-pagination结合Struts2使用时不显示正确的Total,而是显示返回的list的数量?

如图所示:

从action传total参数过来,这边并不显示实际的total,但是其他地方的total是可以传的:

对比了两个方法的区别;

(1)、可以传total的方法;

public String selectPaginationAndFddbr() {
		
	int _rows = IntegerUtil.changeString2Int(request.getParameter("rows"));
	e.setDjgljg(this.ssjg);
	this.total = tStglBgJbxxService.selectCountAndFddbr(e);
	this.rows = tStglBgJbxxService.selectPaginationAndFddbr(e, _rows, this.page);
	return SUCCESS;
}

(2)、不可以传total的方法;

public String selectTzPagination() {
		
	int _rows = IntegerUtil.changeString2Int(request.getParameter("rows"));
	e.setDjgljg(this.ssjg);
	this.total = tStglBgJbxxService.selectTzCount(e);
	this.bgTzList = tStglBgJbxxService.selectTzPagination(e, _rows, this.page); 
		
	return SUCCESS;
}

定义的类的属性

private List<TStglBgJbxxEntity>		rows		= new ArrayList<TStglBgJbxxEntity>();
private TStglBgJbxxEntity			e			= new TStglBgJbxxEntity();
private int							total		= 0;
private List<Map<String, Object>>	bgTzList	= new ArrayList<Map<String, Object>>();
private JSONObject					result;		

发现两个list的泛型不一致,一个Map,一个Entity;应该是这个方面的问题导致的,所以将selectTzPagination改为

public String selectTzPagination() {
		
	int _rows = IntegerUtil.changeString2Int(request.getParameter("rows"));
	e.setDjgljg(this.ssjg);
	this.total = tStglBgJbxxService.selectTzCount(e);
	this.bgTzList = tStglBgJbxxService.selectTzPagination(e, _rows, this.page);
	Map<String, Object> jsonMap = new HashMap<String, Object>();
	jsonMap.put("total", total);
	jsonMap.put("rows", bgTzList);
	result = JSONObject.fromObject(jsonMap);//格式化result   一定要是JSONObject 
		
	return SUCCESS;
}

_struts.xml文件中配置文件里的写法如下;

<action name="selectPaginationAndFddbr" class="TStglBgJbxxAction" method="selectPaginationAndFddbr">
		<result name="success" type="json">
			<param name="contentType">text/html</param>
			<param name="excludeNullProperties">true</param>
		</result>
</action>
		
	<action name="selectTzPagination" class="TStglBgJbxxAction"        method="selectTzPagination">
		<result name="success" type="json">
			<param name="contentType">text/html</param>
			<param name="excludeNullProperties">true</param>
			<param name="root">result</param>
		</result>
	</action>

发现total可以接收成功了;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值