我在JSPX文件中编写如下代码,
<table>
<c:forEach var="var" items="${items}" varStatus="status">
<c:if test="${(status.index) % 4 == 0}">
<tr>
</c:if>
<td>some contents</td>
<c:if test="${(status.index+1) % 4 == 0 || status.last}">
</tr>
</c:if>
</c:forEach>
</table>问题是,<tr>和</tr>会在JSPX中导致编译错误。它将显示"<tr>应该以</tr>结尾“。但是,使用JSP就可以了。
在JSPX中有什么方法可以做到这一点吗?谢谢!
发布于 2012-07-23 16:12:40
我想你可以这样做:
<table>
<c:forEach var="var" items="${items}" varStatus="status">
<c:if test="${(status.index) % 4 == 0}">
<c:out value="<tr>" escapeXml="false"/>
</c:if>
<td>some contents</td>
<c:if test="${(status.index+1) % 4 == 0 || status.last}">
<c:out value="</tr>" escapeXml="false"/>
</c:if>
</c:forEach>
</table>https://stackoverflow.com/questions/11608286
复制相似问题