zoukankan      html  css  js  c++  java
  • jstl的forEach使用和jstl变量实现自增

    <c:forEach items="${reallyChooseSubjectList}" var="reallyChooseSubject"> 
               
               <tr>
                   <td width="20px;">(<%=i %>) </td><td>${reallyChooseSubject.name}</td>
                   <td>
                       <input type="hidden" name="subjectId<%=i %>" id="subjectId<%=i %>" value="${reallyChooseSubject.id }">
               
                </td>
               </tr>
               <tr>
                   <td width="20px;"><td><input type="radio" name="answer<%=i %>" value="A" />A.${reallyChooseSubject.answer_A}</td><td></td>
               </tr>
               <tr>
                   <td width="20px;"><td><input type="radio" name="answer<%=i %>" value="B" />B.${reallyChooseSubject.answer_B}</td><td></td>
               </tr>
               <tr>
                   <td width="20px;"><td>
                       <c:if test="${reallyChooseSubject.answer_C != ''}" scope="page">
                           <input type="radio" name="answer<%=i %>"  value="C" />C.${reallyChooseSubject.answer_C}
                       </c:if>
                   </td><td></td>
               </tr>
               <tr>
                   <td width="20px;"><td>
                       <c:if test="${reallyChooseSubject.answer_D != ''}" scope="page">
                           <input type="radio" name="answer<%=i %>"  value="D" />D.${reallyChooseSubject.answer_D}
                       </c:if>
                   </td><td></td>
               </tr>
               <tr><%i++; %></tr>
               </c:forEach> 

    在循环中变量自增: 

    <%@ page contentType="text/html;charset=gbk" %>
    <%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
    <html>
    <head>
    <title>x</title>
    <meta http-equiv="Content-Type" content="text/html;charset=gbk">
    
    </head>
    <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>
    <br>
    
    </body>
    </html>
  • 相关阅读:
    散列函数的构造方法
    散列表(哈希表)查找
    散列表,哈希表,散列表查找法
    多路查找树之2-3-4树和B树
    多路查找树之2-3树的删除原理
    多路查找树之2-3树的插入原理
    多路查找树之2-3树
    字典:当索引不好用时2
    字典:当索引不好用时
    平衡二叉树的实现原理(代码实现)- 数据结构和算法78
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/4434484.html
Copyright © 2011-2022 走看看