81,092
社区成员
发帖
与我相关
我的任务
分享
//获取运动项目
int id = Integer.parseInt(request.getParameter("sportsItemId"));
SportsItem sportsItem = this.getMatchService().getSportsItemDAO().findById(id);
//获取该项目的所有比赛信息
List<Match> matchs = this.getMatchService().getMatchDAO().getMatchsBySportsItem(sportsItem);
//逐个按照Match获取该Match的报名信息
HashMap<String,List<MatchScores>> matchInfos = new HashMap<String,List<MatchScores>> ();
for(Match m: matchs){
String matchName = m.getMatchName();
List<MatchScores> scores = this.getMatchService().getMatchScoresDAO().getMatchScoresByMatch(m);
matchInfos.put(matchName, scores);
}
//传递运动项目信息
request.setAttribute("item", sportsItem);
//传递所有该项目报名信息
request.setAttribute("matchInfos", matchInfos);
//传递比赛场数
request.setAttribute("matchInfoSize",matchInfos.size());
<body>
${item.itemName }项目共有比赛${matchInfoSize }场,分组情况如下:
<hr/>
<c:forEach items="${matchInfos}" var="matchInfo">
<table width="98%" border="0" cellpadding="2" cellspacing="1"
bgcolor="#D1DDAA" align="center" style="margin-top: 8px">
<tr bgcolor="#E7E7E7">
<td colspan="5">${matchInfo.key}</td>
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22">
<td>运动员编号</td>
<td>运动员姓名</td>
<td>所在单位</td>
<td>跑道</td>
<td>状态</td>
</tr>
<c:forEach items="${matchInfo.value}" var="matchScore">
<tr align='center' bgcolor="#FFFFFF"
onMouseMove="javascript:this.bgColor='#FCFDEE';"
onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td>${matchSocre.sportsMan.sportsNumber}</td>
<td>${matchSocre.sportsMan.sportsmanName}</td>
<td>${matchSocre.sportsMan.college.collegeName}</td>
<td>${matchSocre.runwayCode}</td>
<td>
<c:if test="${matchScore.state==0}">未检录</c:if>
<c:if test="${matchScore.state==1}">已检录未比赛</c:if>
<c:if test="${matchScore.state==2}">已完成比赛</c:if>
</td>
</tr>
</c:forEach>
</table>
</c:forEach>
</body>
//遍历HashMap
String mn = null;
for(Iterator<String> it = matchInfos.keySet().iterator();it.hasNext();){
System.out.println("----------------------------------------------");
mn = it.next();
System.out.println("比赛名称:"+mn);
System.out.println("*************************************");
for(MatchScores m: matchInfos.get(mn)){
System.out.println(m.getSportsMan().getSportsNumber());
System.out.println(m.getSportsMan().getSportsmanName());
System.out.println(m.getRunwayCode());
}
System.out.println("*************************************");
System.out.println("----------------------------------------------");
}