<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 68, comments - 19, trackbacks - 0, articles - 1

    jstl循環(huán)

    Posted on 2010-10-21 22:23 viery 閱讀(6677) 評(píng)論(2)  編輯  收藏 所屬分類(lèi): JavaEE
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="java.util.*" %>

    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <html>
      <head>
        <title>JSTL測(cè)試1--c:forEach循環(huán)</title>
      </head>

      <body>
    一、整數(shù)
        <c:forEach var="i" begin="1" end="10" step="1">
          <c:out value="${i}" />,
        </c:forEach><p>
    二、計(jì)算x的平方
       <table> 
       <tr><th>Value</th> 
        <th>Square</th></tr> 
        <c:forEach var="x" begin="0" end="10" step="2"> 
        <tr><td><c:out value="${x}"/></td> 
            <td><c:out value="${x * x}"/></td></tr> 
       </c:forEach> 
      </table> <p>
    三、字符串"47,52,53,55,46,22,16,2" 分隔.
       <table border="1">
       <c:forTokens items="47,52,53,55,46,22,16,2" delims="," var="dailyPrice">
        <tr><td><c:out value="${dailyPrice}"/></td></tr>
       </c:forTokens>
       </table><p>
    四、使用步長(zhǎng)
       <table> 
        <tr><th>second</th> 
        <th>second</th></tr> 
        <c:forEach var="seconds" begin="0" end="${pageContext.session
    .maxInactiveInterval}" step="60"> 
        <tr><td><c:out value="${seconds}"/></td> 
            <td><c:out value="${seconds}"/></td></tr> 
       </c:forEach> 
      </table> <p>
    五、對(duì)數(shù)組進(jìn)行循環(huán)<p>
      <% int ai[] = {10, 20, 30, 40, 50};
      pageContext.setAttribute("ary", ai);
      %>
      <c:forEach var="i" items="${ary}">
        <c:out value="${i}"/>*
      </c:forEach><p>

     <%
       Cookie c=new Cookie("cookie1","one");
       response.addCookie(c);
     %>

     <% 
      Cookie cookies[]=request.getCookies(); 
      Cookie sCookie=null;  
      String sname=null; 
      String name=null; 
      if(cookies==null) // 如果沒(méi)有任何cookie 
        out.print("none any cookie"); 
      else 
      { 
        //out.print(cookies.length + "<br>"); 
        for(int i=0;i<cookies.length; i++) // 循環(huán)列出所有可用的Cookie 
        { 
         sCookie=cookies[i]; 
          sname=sCookie.getName(); 
          name = sCookie.getValue(); 
          out.println(sname + "->" + name + "<br>"); 
        } 
      }  
    %> 
     
    <table border="1" align="center"> 
       <tr><th>Cookie Name</th> 
        <th>Cookie Value</th></tr> 
        <c:forEach var="cook" items="${pageContext.request.cookies}"> 
        <tr><td><c:out value="${cook.name}"/></td> 
            <td><c:out value="${cook.value}"/></td></tr> 
       </c:forEach> 
      </table> <p>

    六、字符串?dāng)?shù)組循環(huán)
     <% String as[] = {
                "A first string", "La deuxieme string", "Ella troisiemo stringo"
            };
            request.setAttribute("stringArray", as);
     %><p>
     <c:forEach var="string" items="${stringArray}">
      <c:out value="${string}"/><br>
     </c:forEach>
    七、枚舉
     <%
     Hashtable hashtable1 = new Hashtable();
               pageContext.setAttribute("numberMap", hashtable1);
         
            hashtable1.put(new Integer(1), "uno");
            hashtable1.put(new Integer(2), "dos");
            hashtable1.put(new Integer(3), "tres");
            hashtable1.put(new Integer(4), "cuatro");
            hashtable1.put(new Integer(5), "cinco");
            hashtable1.put(new Integer(6), "seis");
            hashtable1.put(new Integer(7), "siete");
            hashtable1.put(new Integer(8), "ocho");
            hashtable1.put(new Integer(9), "nueve");
            hashtable1.put(new Integer(10), "diez");

            java.util.Enumeration enumeration = hashtable1.keys();
            pageContext.setAttribute("enumeration", enumeration);
    %>

       <c:forEach var="item" items="${enumeration}" begin="2" end="10" step="2">
         <c:out value="${item}"/><br>
       </c:forEach><p>
    八、map<p>
       <c:forEach var="prop" items="${numberMap}" begin="1" end="5">
         <c:out value="${prop.key}"/> = <c:out value="${prop.value}"/><br>
       </c:forEach>

     

     </body>
    </html>

    Feedback

    # re: jstl循環(huán)  回復(fù)  更多評(píng)論   

    2015-11-02 15:43 by aaaaaaaaaaaaaa
    <script>alert('aa')<script>

    # re: jstl循環(huán)  回復(fù)  更多評(píng)論   

    2015-11-02 15:45 by aaaaaaaaaaaaaa
    /><script>alert('aa')<script>
    主站蜘蛛池模板: 1000部拍拍拍18免费网站| 亚洲VA中文字幕不卡无码| 免费一级特黄特色大片在线| 亚洲宅男天堂在线观看无病毒| 国产亚洲人成网站在线观看| 久久亚洲国产成人影院| 一区二区三区无码视频免费福利| 大香人蕉免费视频75| 图图资源网亚洲综合网站| 在线观看亚洲网站| 黄瓜视频高清在线看免费下载| 亚洲av永久无码精品漫画| 久久久精品免费视频| 国产大片91精品免费观看男同| 亚洲精品国产福利在线观看| a在线视频免费观看在线视频三区| 久久久久久国产精品免费免费| 亚洲一卡2卡4卡5卡6卡残暴在线| 女人体1963午夜免费视频| 一区二区三区亚洲| 亚洲一区二区在线免费观看| 亚洲国产成人无码av在线播放| 少妇无码一区二区三区免费| 亚洲综合在线成人一区| 最新猫咪www免费人成| 国产精品亚洲综合五月天| 足恋玩丝袜脚视频免费网站| 亚洲va久久久噜噜噜久久狠狠 | 无人视频在线观看免费播放影院| 韩国免费一级成人毛片| 亚洲视频国产精品| 人妻无码一区二区三区免费| 久久亚洲国产中v天仙www| 免费无码av片在线观看| 亚洲a视频在线观看| 国产成人亚洲精品影院| 一级做a爱过程免费视| 亚洲中文字幕无码爆乳av中文| 久久青草91免费观看| 在线观看亚洲专区| 亚洲高清在线mv|