这是我的代码在jsp:
<script>
var myArray = [];
</script>
<c:forEach var="attributes" items="FROMthisBEAN" varStatus="vStatus" >
<script>
//Executes for each iteration. Do something COOL.
myArray.push("Something from this iteration");
</script>
</c:forEach>
现在请考虑以下各点:
<script>
var myArray = [];
<c:forEach var="attributes" items="FROMthisBEAN" varStatus="vStatus" >
myArray.push("Something from this iteration");
</c:forEach>
</script>
<c:forEach var="attributes" items="FROMthisBEAN" varStatus="vStatus" >
//Executes for each iteration. Do something COOL.
</c:forEach>
Both the codes give me the same output.
The question is which one is better when it comes to performance?
In the first case the script tag inside c:forEach repeats again and again.
But in the second case I m creating one more c:forEach which is already present in the JSP.
Totally lost here. Please advise.