JSTL 學習筆記

1.<c:forEach>錯誤筆記:html

Property 'url' not found on type java.lang.Stringjava

<c:forEach var="bean1" items="useMenusList">
   <li class="topmenu" id="home">
      <ul class="topmenu" style="list-style-type:none" >
         <li><a href="${ctx}${bean1.url}" tabindex="-1">${bean1.displayNameCn}</a></li>
         <li><a href="${ctx}${bean1.url}" tabindex="-1">${bean1.displayNameEn}</a></li>
      </ul>
   </li>
</c:forEach>

 由於<c:forEach>標籤下的items沒有加EL表達式的標籤「${}」學習

 

2.<c:choose>標籤學習:ui

<c:choose>就像在Java switch語句,它可讓你在一些替代方案之間選擇。switch語句中有case語句,<c:choose>標籤具備<c:when>標籤。switch語句中有默認default子句來指定一個默認的行爲,相似的方式<c:choose>以<c:otherwise>做爲default語句。url

 

屬性:code

<c:choose>標籤沒有任何屬性。htm

<c:when>標記有一個屬性,在下文列出。blog

<c:otherwise>標籤沒有任何屬性。it

 

<c:when>標籤具備如下屬性:io

屬性     描述 Required     Default

test   計算條件    Yes       None

 

<ul class="pager">
	<c:choose>
		<c:when test="${__action.pageIndex==0}">
			<li><a href="#">沒有找到相關的用戶</a></li>
		</c:when>
		<c:otherwise>
		<c:if test="${__action.pageIndex>1}">
			<li><a href="purchaseAction!listPurchase.do?pageIndex=1&&supplierid=${__action.purchaseDetail.supplierid}&&productid=${ __action.purchaseDetail.productid}">首頁</a></li>
			<li><a
				href="purchaseAction!listPurchase.do?pageIndex=${__action.pageIndex-1}&&supplierid=${__action.purchaseDetail.supplierid}&&productid=${ __action.purchaseDetail.productid}">上一頁</a></li>
		</c:if>
			<li><a>當前頁數:${__action.pageIndex}/${__action.pageSize}</a></li>
		<c:if test="${__action.pageIndex<__action.pageSize}">
			<li><a
				href="purchaseAction!listPurchase.do?pageIndex=${__action.pageIndex+1}&&supplierid=${__action.purchaseDetail.supplierid}&&productid=${ __action.purchaseDetail.productid}">下一頁</a></li>
			<li><a
				href="purchaseAction!listPurchase.do?pageIndex=${__action.pageSize}&&supplierid=${__action.purchaseDetail.supplierid}&&productid=${ __action.purchaseDetail.productid}">末頁</a></li>
		</c:if>
		</c:otherwise>
	</c:choose>
</ul>
相關文章
相關標籤/搜索