jstl变量实现自增

Java代码   jstl变量实现自增
  1. <c:forEach items="${reallyChooseSubjectList}" var="reallyChooseSubject">   
  2.           
  3.         <tr>  
  4.             <td width="20px;">(<%=i %>) </td><td>${reallyChooseSubject.name}</td>  
  5.             <td>  
  6.                 <input type="hidden" name="subjectId<%=i %>" id="subjectId<%=i %>" value="${reallyChooseSubject.id }">  
  7.           
  8.             </td>  
  9.         </tr>  
  10.         <tr>  
  11.             <td width="20px;"><td><input type="radio" name="answer<%=i %>" value="A" />A.${reallyChooseSubject.answer_A}</td><td></td>  
  12.         </tr>  
  13.         <tr>  
  14.             <td width="20px;"><td><input type="radio" name="answer<%=i %>" value="B" />B.${reallyChooseSubject.answer_B}</td><td></td>  
  15.         </tr>  
  16.         <tr>  
  17.             <td width="20px;"><td>  
  18.                 <c:if test="${reallyChooseSubject.answer_C != ‘‘}" scope="page">  
  19.                     <input type="radio" name="answer<%=i %>"  value="C" />C.${reallyChooseSubject.answer_C}  
  20.                 </c:if>  
  21.             </td><td></td>  
  22.         </tr>  
  23.         <tr>  
  24.             <td width="20px;"><td>  
  25.                 <c:if test="${reallyChooseSubject.answer_D != ‘‘}" scope="page">  
  26.                     <input type="radio" name="answer<%=i %>"  value="D" />D.${reallyChooseSubject.answer_D}  
  27.                 </c:if>  
  28.             </td><td></td>  
  29.         </tr>  
  30.         <tr><%i++; %></tr>  
  31.         </c:forEach>   



在循环中变量自增: 

Java代码   jstl变量实现自增
    1. <%@ page contentType="text/html;charset=gbk" %>  
    2. <%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>  
    3. <html>  
    4. <head>  
    5. <title>x</title>  
    6. <meta http-equiv="Content-Type" content="text/html;charset=gbk">  
    7.   
    8. </head>  
    9. <body>  
    10. <c:set var="index" value="0" />  
    11. <c:forEach var="x" begin="1" end="9" step="1">  
    12. <c:set var="index" value="${index+1}" />  
    13. index:${index}  
    14. x:${x }  
    15. <br>  
    16.   
    17. </c:forEach>  
    18. <br>  
    19.   
    20. </body>  
    21. </html>  

jstl变量实现自增,布布扣,bubuko.com

jstl变量实现自增

上一篇:模态对话框 bootstrap-modal.js


下一篇:js 正则表达式