我有一个 JSP,我在其中声明一个整数值
<c:set var="rowCount" value="0" />
我试图在几个标签中使用它
<product:attribute rowCount="${rowCount}" attrKey="${msg_site}:" attrValue="${product.site}" />
<product:attribute rowCount="${rowCount}" attrKey="${msg_name}:" attrValue="${product.name}" />
<product:attribute rowCount="${rowCount}" attrKey="${msg_type}:" attrValue="${product.type}" />
在每个标签内,我都覆盖了 rowCount 值
<%@ attribute name="rowCount" required="true" %>
<c:if test="${rowCount >= 2}" >
</div>
<div class="col-md-12 col-sm-12 col-xs-12 ">
<c:set var="rowCount" value="${0}" />
</c:if>
<c:set var="rowCount" value="${rowCount +1}" />
但似乎我在每个标签中为 rowCount 声明了一个新变量。如何重用该值而不是声明一个新变量?