现在做一个web项目,需要实现以下功能
选着不同的选项,显示不同的内容。
那么显然需要用到JSTL里的选择标签。
下面是实现方案:
前端的数据是后端服务给的,比如,grade字段是true则表明已经评分,id==null则表明没有提交。
<!-- 作业列表 -->
<div id="homeworkDetail">
<div class="tabHomework">
<input type="radio" name="homework" value="1" checked="checked" /><label for="" class="checked">全部</label>
<input type="radio" name="homework" value="2" /> <label for="">未提交</label>
<input type="radio" name="homework" value="3" /> <label for="">未评分</label>
<input type="radio" name="homework" value="4" /> <label for="">已评分</label>
</div>
<!-- 全部列表 -->
<ul class="homeWorkUL" id="all">
<c:forEach var="mymap" items="${map}">
<c:forEach var="submitMap" items="${mymap.value}" varStatus="abc">
<li><a href="mainView/courseHomework/courseHomeworkDetailLook.jsp?AssignmentSubmit=${submitMap.value}">
<ul class="subHomeWorkUL">
<li id="realName">${submitMap.value.realName}</li>
<li id="userName">${submitMap.key}</li>
<li id="Grade">
<c:choose>
<c:when test="${submitMap.value.id == null}">未提交</c:when>
<c:when test="${submitMap.value.rejected}">被打回</c:when>
<c:when test="${submitMap.value.graded}">${submitMap.value.gradePoint}</c:when>
<c:otherwise> <strong>未评分</strong> </c:otherwise>
</c:choose>
</li> </ul>
</a>
</li>
</c:forEach>
</c:forEach>
</ul>
<!-- 未提交 -->
<ul class="homeWorkUL" id="noSubmit">
<c:forEach var="mymap" items="${map}">
<c:forEach var="submitMap" items="${mymap.value}" varStatus="abc">
<c:choose>
<c:when test="${submitMap.value.id == null}">
<li><a href="mainView/courseHomework/courseHomeworkDetailLook.jsp">
<ul class="subHomeWorkUL">
<li id="realName">${submitMap.value.realName}</li>
<li id="userName">${submitMap.key}</li>
<li id="state">未提交</li>
</ul>
</a></li>
</c:when>
<c:otherwise></c:otherwise>
</c:choose>
</c:forEach>
</c:forEach>
</ul>
<!-- 未评分 -->
<ul class="homeWorkUL" id="noEvaluate">
<c:forEach var="mymap" items="${map}">
<c:forEach var="submitMap" items="${mymap.value}" varStatus="abc">
<c:choose>
<c:when test="${submitMap.value.id!=null && submitMap.value.graded eq false}">
<li>
<a href="mainView/courseHomework/courseHomeworkDetailLook.jsp">
<ul class="subHomeWorkUL">
<li id="realName">${submitMap.value.realName}</li>
<li id="userName">${submitMap.key}</li>
<li id="state">未评分</li>
</ul>
</a></li>
</c:when>
<c:otherwise></c:otherwise>
</c:choose>
</c:forEach>
</c:forEach>
</ul>
<!-- 已评分 -->
<ul class="homeWorkUL" id="evaluate">
<c:forEach var="mymap" items="${map}">
<c:forEach var="submitMap" items="${mymap.value}" varStatus="abc">
<c:choose>
<c:when test="${submitMap.value.graded}">
<li>
<a href="mainView/courseHomework/courseHomeworkDetailLook.jsp">
<ul class="subHomeWorkUL">
<li id="realName">${submitMap.value.realName}</li>
<li id="userName">${submitMap.key}</li>
<li id="Grade">${submitMap.value.gradePoint}</li>
</ul>
</a>
</li>
</c:when>
<c:otherwise></c:otherwise>
</c:choose>
</c:forEach>
</c:forEach>
</ul>
</div>
</div>
</div>
版权声明:本文为博主原创文章,转载请注明本博客地址!
时间: 2024-11-09 09:43:11