Rising Sun

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            148 隨筆 :: 0 文章 :: 22 評(píng)論 :: 0 Trackbacks
          <2008年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(10)

          隨筆分類

          隨筆檔案

          相冊(cè)

          java--->ajax

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          . 條件標(biāo)簽
              JSTL: 
           1 <c:if test="${user.password == 'hello'}">
           2     <c:choose>
           3         <c:when test="${user.age <= 18}">
           4             <font color="blue" />
           5         </c:when>
           6         <c:when test="${user.age <= 30 && user.age > 18}">
           7             <font color="red" />
           8         </c:when>
           9         <c:otherwise>
          10             <font color="green" />
          11         </c:otherwise>
          12     </c:choose>
          13 </c:if>
              Struts2:
          1 <s:if test="#user.age <= 18">
          2     <font color="blue" />
          3 </s:if>
          4 <s:elseif test="#user.age <= 30 && user.age > 18">
          5     <font color="red" />
          6 </s:elseif>
          7     <font color="green" />
          8 </s:else>

          2. 迭代標(biāo)簽
              JSTL:
          1 <c:forEach var="user" items="${users}">
          2     <c:out value="${user.userName}" />
          3 </c:forEach>
          4 <!-- 迭代固定次數(shù) -->
          5 <c:forEach var="i" begin="1" end="10" step="3">
          6     <c:out value="${i}" />
          7 </c:forEach>
          8 <!-- 這種循環(huán)相當(dāng)于for(int i=1; i<10; i++), 其中step是指迭代的步長(zhǎng),默認(rèn)為1. -->
              Struts2:
          1 <s:iterator value="#users" status="stuts">                
          2     <s:if test="#stuts.odd == true">   <!-- 判斷是否為奇數(shù)行 -->
          3         <s:property value="userName" />
          4     </s:if>
          5     <s:else>
          6         <s:property value="passWord" />
          7     </s:else>
          8 </s:iterator>

          3. URL相關(guān)標(biāo)簽
              JSTL:
           1 <!-- 絕對(duì)路徑 -->
           2 <c:import url="http://127.0.0.1:8080/hello/hello.jsp" />
           3 <!-- 相對(duì)路徑 -->
           4 <c:import url="hello.jsp" />
           5 <!-- Encode -->
           6 <href="<c:url value='hello.jsp'><c:param name='userName' value='cyanbomb' /></c:url>"></a>
           7 <!-- 傳遞參數(shù)到指定的URL -->
           8 <c:import url="hello.jsp" charEncoding="gb2312" >
           9     <c:param name="userName" value="cyanbomb" />
          10 </c:import>
          11 <!-- URL重定向 -->
          12 <c:redirect url="${myurl}" />
          13 <!-- 構(gòu)造URL -->
          14 <c:url value="myurl" var="hello.jsp" scope="session">
          15     <c:param name="userName" value="cyanbomb" />
          16 </c:url>
              Struts2:
          1 <href='<s:url value="/hello.jsp" />'>Hello</a><br />
          2 <s:url id="url" value="/hello.jsp">
          3     <s:param name="name">cyanbomb</s:param>
          4 </s:url>        
          5 <s:a href="%{url}">Hello</s:a>

          解除的疑問,list遍歷問題

          像這樣一個(gè)list,里面有3條記錄,每條記錄包含兩個(gè)對(duì)象,我把結(jié)果集(lstRooms)request到了頁(yè)面,想遍歷顯示RrmRooms里的id,和RrmRoomType里的name.
          我用JSTL實(shí)現(xiàn)如下:
          1 <table>
          2     <c:forEach var="rm" items="${lstRooms}">
          3         <tr>
          4             <td>${rm[0].id}</td>
          5             <td>${rm[1].name}</td>
          6         <tr>
          7     </c:forEach>
          8 </table>
          STRUTS2實(shí)現(xiàn)如下:
          1<table>
          2     <s:iterator value="#lstRooms" status="stat">
          3         <tr>
          4             <td><s:property value="#lstRooms[#stat.index][0].id" /></td>
          5             <td><s:property value="#lstRooms[#stat.index][1].name" /></td>
          6         <tr>
          7     </s:iterator>
          8</table>
          posted on 2008-07-30 09:02 brock 閱讀(296) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 甘南县| 伊吾县| 武宁县| 富蕴县| 昌邑市| 沽源县| 卢湾区| 宁陵县| 天津市| 珲春市| 宜昌市| 新竹县| 和顺县| 北票市| 东光县| 手机| 凤冈县| 南川市| 武汉市| 如东县| 张掖市| 岑溪市| 日照市| 合肥市| 平利县| 阳东县| 龙江县| 民勤县| 无为县| 延川县| 梓潼县| 河西区| 桃江县| 永嘉县| 自治县| 榆中县| 宁河县| 芮城县| 公主岭市| 林口县| 漳浦县|