jstl经典用法

时间:2022-12-18 13:01:08

jstl的forEach使用和set变量实现自增:

<body>
  <c:set var="index" value="0" />
  <c:forEach var="x" begin="1" end="9" step="1">
    <c:set var="index" value="${index+1}" />
    index:${index}
    x:${x }
    <br />
  </c:forEach>
</body>

javascript 取 jstl c:set中变量:

    <script type="text/javascript">
//到JSP底部取jstl c:set中变量 才能取到
var index = '${index}';
alert(index);
</script>
</html>

原文:艺意