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. 榪唬鏍囩
JSTL:
1 <c:forEach var="user" items="${users}">
2 <c:out value="${user.userName}" />
3 </c:forEach>
4 <!-- 榪唬鍥哄畾嬈℃暟 -->
5 <c:forEach var="i" begin="1" end="10" step="3">
6 <c:out value="${i}" />
7 </c:forEach>
8 <!-- 榪欑寰幆鐩稿綋浜巉or(int i=1; i<10; i++), 鍏朵腑step鏄寚榪唬鐨勬闀?榛樿涓?. -->
Struts2:
1 <s:iterator value="#users" status="stuts">
2 <s:if test="#stuts.odd == true"> <!-- 鍒ゆ柇鏄惁涓哄鏁拌 -->
3 <s:property value="userName" />
4 </s:if>
5 <s:else>
6 <s:property value="passWord" />
7 </s:else>
8 </s:iterator>
3. URL鐩稿叧鏍囩
JSTL:
1 <!-- 緇濆璺緞 -->
2 <c:import url="http://127.0.0.1:8080/hello/hello.jsp" />
3 <!-- 鐩稿璺緞 -->
4 <c:import url="hello.jsp" />
5 <!-- Encode -->
6 <a href="<c:url value='hello.jsp'><c:param name='userName' value='cyanbomb' /></c:url>"></a>
7 <!-- 浼犻掑弬鏁板埌鎸囧畾鐨刄RL -->
8 <c:import url="hello.jsp" charEncoding="gb2312" >
9 <c:param name="userName" value="cyanbomb" />
10 </c:import>
11 <!-- URL閲嶅畾鍚?nbsp;-->
12 <c:redirect url="${myurl}" />
13 <!-- 鏋勯燯RL -->
14 <c:url value="myurl" var="hello.jsp" scope="session">
15 <c:param name="userName" value="cyanbomb" />
16 </c:url>
Struts2:
1 <a 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>
瑙i櫎鐨勭枒闂紝list閬嶅巻闂

鍍忚繖鏍蜂竴涓猯ist,閲岄潰鏈?鏉¤褰?姣忔潯璁板綍鍖呭惈涓や釜瀵硅薄,鎴戞妸緇撴灉闆?lstRooms)request鍒頒簡欏甸潰,鎯抽亶鍘嗘樉紺篟rmRooms閲岀殑id,鍜孯rmRoomType閲岀殑name.
鎴戠敤JSTL瀹炵幇濡備笅:
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瀹炵幇濡備笅:
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>
寰呮洿鏂?..
----------------------------
鐝嶆儨鍘熷垱,璋㈢粷鐩楃増! - cYanbomb

]]>