我有一个JSP代码如下。我想在输入表单中插入一个if / else循环。如果$ {experimentList.type} == GRO-seq,那么我希望值为"正数"和"否定"。否则,我希望按钮上的值显示为" bigWig File"和" bigWig文件"。我广泛搜索了这种类型的循环,但没有找到可行的解决方案。谢谢!
<c:forEach items="${experimentList}" var="experimentList">
<tr>
<td>${experimentList.FGCID}</td>
<td>${experimentList.person}</td>
<td>${experimentList.type}</td>
<td>${experimentList.factor}</td>
<td>${experimentList.tissue}</td>
<td>${experimentList.condition}</td>
<td>${experimentList.sample}</td>
<td>${experimentList.name}</td>
<td>${experimentList.date}</td>
<td>${experimentList.comments}</td>
<form action="${pageContext.request.contextPath}/getfiles" method="post">
<td><input type="submit" name="track_1" value="positive" /><input type="hidden" name="track1" value="${experimentList.track1}" /></td>
<td><input type="submit" name="track_2" value="negative" /><input type="hidden" name="track2" value="${experimentList.track2}" /></td>
</form>
答案 0 :(得分:0)
您可以将代码更新为以下
<td>
<c:choose>
<c:when test="${experimentList.type eq 'GRO-seq'}">
<input type="submit" name="track_1" value="positive" />
</c:when>
<c:otherwise>
<input type="submit" name="track_1" value="bigWig File" />
</c:otherwise>
</c:choose>
<input type="hidden" name="track1" value="${experimentList.track1}" />
</td>
<td>
<c:choose>
<c:when test="${experimentList.type eq 'GRO-seq'}">
<input type="submit" name="track_1" value="negative" />
</c:when>
<c:otherwise>
<input type="submit" name="track_2" value="bigWig File" />
</c:otherwise>
</c:choose>
<input type="hidden" name="track2" value="${experimentList.track2}" />
</td>