jstl经典用法

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>

原文:艺意

 

posted on 2017-01-09 23:48  艺意  阅读(370)  评论(0编辑  收藏  举报