我想在jsp页面中设置一个变量,如果它是某个值,然后测试它是否存在,然后在某一行之后创建一个表行。当我尝试时没有任何事情发生。
<c:forEach var="row" items="${regData}" varStatus='rowstatus'>
<tr>
<c:choose>
<c:when test="${row.values[10]=='PROG'}">
<c:set var="postTitle" value="Anttermin" scope="request"/>
</c:when>
</tr>
</c:forEach>
<c:if test="${fn:length(postTitle) == 'PROG'}">
<tr>Anttermin</tr>
</c:if>
答案 0 :(得分:0)
试试这个
<c:forEach var="row" items="${regData}" varStatus='rowstatus'>
<tr>
<c:choose>
<c:when test="${row.values[10] eq 'PROG'}">
<c:set var="postTitle" value="Anttermin" scope="request"/>
</c:when>
</tr>
</c:forEach>
<c:if test="${fn:length(postTitle) eq 'PROG'}">
<tr>Anttermin</tr>
</c:if>
对于字符串,您需要使用.equals
代替==
答案 1 :(得分:0)
成功跟随jsp
</tr>
<c:choose>
<c:when test="${row.values[10] == 'PROG' && row.values[5] != 'AVBR'}">
<tr>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}">Antagningstermin</td>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}${style}">ANT</td>
<td class="tableCell${cellStyle}"></td>
<td class="tableCell${cellStyle}">${row.values[8]}</td>
<td class="tableCell${cellStyle}"></td>
</tr>
</c:when>
</c:choose>