当前位置: 代码迷 >> ASP >> <ww:iterator> 迭代 Map<String,List<AspectVo>>
  详细解决方案

<ww:iterator> 迭代 Map<String,List<AspectVo>>

热度:1009   发布时间:2012-08-24 10:00:21.0
<ww:iterator> 迭代 Map<String,List<AspectVo>>

这段时间在做一个报表,关于<ww:iterator> 迭代?Map<String,List<AspectVo>> ?AspectVo是个对象,

具体页面如下:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
   <th width="100%" height="30px" align="center" valign="middle" class="list_gridRB" colspan="6">二级分类统计表(本级接收)</th>
   </tr>
    <tr>
	<th rowspan="2" colspan="2" align="center" valign="middle" class="list_gridRB">内容分类</th>
	<th colspan="4" height="20" align="center" valign="middle" class="list_gridRB">网上信访量</th>
	</tr>
	<tr>
	<th height="20" align="center" valign="middle" class="list_gridRB">本期</th>
	<th height="20" align="center" valign="middle" class="list_gridRB">上期</th>
	<th height="20" align="center" valign="middle" class="list_gridRB">环比</th>
	<th height="20" align="center" valign="middle" class="list_gridRB">占比</th>
	</tr>
	<ww:iterator value="object.keySet()" id="key">
	<tr>
	<td width="20%" align="center" valign="middle" class="list_gridRB" rowspan="<ww:property value="(object.get(#key)).size()"/>"><ww:property value="#key"/></td>
	<ww:iterator value="object.get(#key)" status="status">
	<ww:if test="#status.count == 1">
	 <td width="20%" height="20"  ><ww:property value="aspectName"/></td>
	<td height="20"  ><ww:property value="base"/></td>
	<td height="20" ><ww:property value="pre"/></td>
	<td height="20"  >
	 <ww:if test="hPecent=='.00%'">0.00%</ww:if>
	<ww:else><ww:property value="hPecent"/></ww:else>
	</td>
	<td height="20" align="center" valign="middle" class="list_gridRB">
	<ww:if test="zPecent=='.00%'">0.00%</ww:if>
	 <ww:else><ww:property value="zPecent"/></ww:else>
	 </td>
	</ww:if>
	</ww:iterator>
	</tr>
	<ww:iterator value="object.get(#key)" status="sta">
	<ww:if test="#sta.count > 1">
	<tr>
	<td height="20"  ><ww:property value="aspectName"/></td>
	<td height="20"  ><ww:property value="base"/></td>
	<td height="20"  ><ww:property value="pre"/></td>
	 <td height="20"  >
	 <ww:if test="hPecent=='.00%'">0.00%</ww:if>
	 <ww:else><ww:property value="hPecent"/></ww:else>
	 </td>
	  <td height="20" align="center" valign="middle"  >
	<ww:if test="zPecent=='.00%'">0.00%</ww:if>
	 <ww:else><ww:property value="zPecent"/></ww:else>
	 </td>
	  </tr>
	 </ww:if>   
		</ww:iterator>
	</ww:iterator>
 </table>

? AspectVo的代码:注意里面的公式

/**
 * 
 */
package com.hdzx.model;

import java.text.DecimalFormat;

/**
 * @author chendj
 *
 */
public class AspectVo {
	private String aspectName;//内容分类Id
	private Integer base;//本期数量
	private Integer pre;//上期数量
	private String hPecent;//环比  = (本期数量-上期数量)/上期数量*100%
	private String zPecent;//占比  = 本期数量/本期总数*100%
	
	public static Integer SUM = 0;//本期总数
	
	public String getAspectName() {
		return aspectName;
	}
	public void setAspectName(String aspectName) {
		this.aspectName = aspectName;
	}
	public Integer getBase() {
		return base;
	}
	public void setBase(Integer base) {
		this.base = base;
	}
	public Integer getPre() {
		return pre;
	}
	public void setPre(Integer pre) {
		this.pre = pre;
	}
	public String getHPecent() {
		DecimalFormat df1 = new DecimalFormat("##.00%"); 
		if(base != 0)
			hPecent = df1.format((double)(base - pre)/base);
		else
			hPecent = df1.format(Double.valueOf(-pre));
		return hPecent;
	}
	public void setHPecent(String pecent) {
		hPecent = pecent;
	}
	public String getZPecent() {
		DecimalFormat df1 = new DecimalFormat("##.00%"); 
		if(SUM != 0)
			zPecent = df1.format((double)(base)/SUM);
		else
			zPecent = "0.00%";
		return zPecent;
	}
	public void setZPecent(String pecent) {
		zPecent = pecent;
	}
	
	
	
}
?

?

  相关解决方案