浅尝JSTL标准标签库

来源:互联网 发布:java抽奖系统源代码 编辑:程序博客网 时间:2024/05/21 14:09

 JSTL常用标签:替代在页面写java代码

<c:choose>,<c:when>,<c:otherwise>标签和if-esle判断语句类似

如:

<c:choose>

  <c:when test="${category.parent.parent.parent.id eq '1' }">
  <c:set var="categoryList1" value="${fnc:getCategoryList(site.id, category.parent.id, -1, null)}"></c:set>
  </c:when>
  <c:otherwise>
  <c:set var="categoryList1" value="${fnc:getCategoryList(site.id, category.parent.parent.id, -1, null)}"></c:set>
</c:otherwise>

</c:choose>


<c:if >标签和if判断语句类似

<c:forEach>标签和for增强型语句类似

<fmt:formatDate>格式化时间格式

如:

<c:if test="${category.module eq 'report'}">
<ul class="tab-content-ul">
<c:if test="${page.count>0}">
<c:forEach items="${page.list}" var="report">
<li >
<span class="pull-right" >
<fmt:formatDate value="${report.updateDate}" pattern="yyyy.MM.dd" />
<c:choose>
<c:when test="${fnc:store(report.id)}">
<a id="${report.id}" href="#" onclick="cancelS'${report.id}')" style="color:#115a6f">
取消
</a>
</c:when>
<c:otherwise>
<a id="${report.id}" href="#" onclick="shoucang('${report.id}')" style="color:#115a6f">
收藏 
</a>
</c:otherwise>
</c:choose>
</span>
<a href="#" onclick="show('${report.resId}','${report.reportSuffix}')" title="${fns:abbr(report.reportName,100)}" style="color:#115a6f">
${fns:abbr(report.reportName,100)}
</a>
</li>
</c:forEach>
</c:if>
</ul>
</c:if>


常用JSTL标准标签如上所示,全面的JSTL标准标签库请查询下面的网站

http://elf8848.iteye.com/blog/245559

0 0