<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)  編輯  收藏 所屬分類: 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) // 如果沒有任何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>
    主站蜘蛛池模板: 亚洲精品视频在线观看视频| 国产日韩精品无码区免费专区国产| 国产专区一va亚洲v天堂| 91手机看片国产永久免费| 免费无码黄网站在线看| 免费国产a理论片| 亚洲中文字幕无码爆乳| 亚洲电影唐人社一区二区| 亚洲精品美女久久777777| 免费一级一片一毛片| 精品国产免费观看久久久 | 日韩高清在线免费观看| 最近免费中文在线视频| 精品国产麻豆免费人成网站| 亚洲阿v天堂在线2017免费| 国产精品无码亚洲精品2021| 亚洲色大网站WWW永久网站| 亚洲av永久无码嘿嘿嘿| 亚洲码在线中文在线观看| 亚洲综合一区二区国产精品| 久久青青草原亚洲AV无码麻豆| 亚洲码国产精品高潮在线| 亚洲伊人久久综合影院| 亚洲福利精品一区二区三区| 国产一精品一aⅴ一免费| 日本特黄特色aa大片免费| 免费鲁丝片一级在线观看| 在线A级毛片无码免费真人| 国内一级一级毛片a免费| 精品免费国产一区二区三区| 免费看www视频| 国产乱弄免费视频| 免费成人午夜视频| 亚洲精品成人在线| a级亚洲片精品久久久久久久 | 国产精品无码亚洲精品2021| 国产成人高清亚洲一区91| 男男黄GAY片免费网站WWW| 思思久久99热免费精品6| 国产激情久久久久影院老熟女免费| free哆拍拍免费永久视频|