如何在JSP页面使用JSTL标签获取List的元素个数

1. 工程中要有:jstl.jar 和 standard.jar 这两个jar包。

2. 页面中导入JSTL core和JSTL functions标签库:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

3 . 例如,你要测试一个List变量elements中的元素个数是否为0,就可以像下边这样:

<c:when test="${fn:length(m_messages.elements)>0}">

......

</c:when>

<c:otherwise>
.....

</c:otherwise>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本系统特色: 1、前台完全生成静态HTML 2、栏目是无级分类的,您可以随意设置栏目,只要您能想到的,多少都可以:) 3、制作简单,由于本人以前曾经使用过动易网站管理系统,所以在功能方面向动易文章管理系统靠拢, 前台制作采用标签制,分为系统标签和用户自义义标签两种,系统标签是自代的,用户不可以修改,而自定义标签则是用户根据相应的功能自己定制出来的,固此,可以自行删除或修改! 4、秉承JAVA开源理念,本新闻发布系统开源! 5、本系统采用到的技术:JSP+Struts+JSTL+EL,我本人喜欢JSTL+EL的组合方式,他不景向页面美观! 6、mysql.sql这个文件是mysql的脚本文件,您可以用它来创建数据库! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- saved from url=(0043)http://www.chinahongker.com/index/index.asp --> <HTML><HEAD><TITLE>E鹰网络工作室</TITLE><LINK href="/images/css.css" type=text/css rel=stylesheet><LINK href="/images/welab.css" type=text/css rel=stylesheet> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <STYLE type=text/css>BODY { MARGIN: 0px; BACKGROUND-COLOR: #930000 } .youhei { BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #333333 1px solid; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-LEFT-COLOR: #333333; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #333333; COLOR: #000000; BORDER-TOP-COLOR: #333333; TEXT-DECORATION: none } .baizi { FONT-SIZE: 12px; COLOR: #ffffff; TEXT-DECORATION: none } .cuzi { FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #000000; TEXT-DECORATION: none } .baiheicu { FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #ffffff; TEXT-DECORATION: none } .shier { FONT-SIZE: 12px; COLOR: #000000; TEXT-DECORATION: none } .lanzi { FONT-SIZE: 12px; COLOR: #2d7066; TEXT-DECORATION: none } .zi { FONT-SIZE: 12px; COLOR: #333333; TEXT-DECORATION: none } .zi1 { FONT-SIZE: 12px; COLOR: #000000; TEXT-DECORATION: none } .style1 { FONT-SIZE: 9px; COLOR: #690102 } A.baazi:link { COLOR: #ffffff; TEXT-DECORATION: none } A.baazi:visited { COLOR: #ffffff; TEXT-DECORATION: none } A.baazi:hover { COLOR: #ffffff; TEXT-DECORATION: none } </STYLE> <META content="MSHTML 6.00.3790.2541" name=GENERATOR></HEAD> <BODY> <TBODY> <TR> <TD> <div align="center"> <table width="800" border="0"> <!--DWLayoutTable--> <tr> <td width="196" height="18" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="196" height="16" background="/images/index_13.jpg"> </td> </tr> </table></td> <td width="594" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="594" height="16" valign="top" background="/images/index_13.jpg"><script language='JavaScript' type='text/JavaScript' src='/Article/js/menu.js'></script> <script type='text/javascript' language='JavaScript1.2' src='/Article/js/stm31.js'></script> <script language='JavaScript1.2' type='text/JavaScript' src='/Article/js/ShowClass_Menu.js'></script></td> </tr> </table></td> </tr> </table> </div> <TABLE height="100%" cellSpacing=0 cellPadding=0 width=800 align=center bgColor=#ffffff border=0><TBODY><TR vAlign=bottom> <TR> <TD vAlign=top background=/images/bg_1.jpg colSpan=10> <TABLE cellSpacing=3 cellPadding=0 width="100%" border=0><TBODY> <TR> <TD width="95%" height=1216> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg height=43><IMG height=43 alt="" src="/images/index_22.jpg" width=39></TD> <TD class=baiheicu width="62%" background=/images/index_24.jpg> <DIV align=center>通告</DIV></TD> <TD class=baiheicu width="19%" background=/images/index_24.jpg> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD vAlign=top bgColor=#ffffff colSpan=2 height=150> <TABLE class=zi1 cellSpacing=0 cellPadding=0 width="100%" align=center border=0> <TBODY> <TR> <TD width="5%"> </TD> <TD width="82%" height=150> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD height=10> </TD> </TR> <TR> <TD height=140> <MARQUEE onmouseover=this.stop() onmouseout=this.start(); scrollAmount=1 direction=up width=180 height=150> </MARQUEE></TD> </TR> <TR> <TD height=10> </TD> </TR> </TBODY> </TABLE></TD> <TD width="5%"> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg><IMG height=43 alt="" src="/images/index_22.jpg" width=39></TD> <TD class=baiheicu width="62%" background=/images/index_24.jpg> <DIV align=center>热门文章</DIV></TD> <TD class=baiheicu width="19%" background=/images/index_24.jpg> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD vAlign=top bgColor=#ffffff colSpan=2 height=160> <TABLE class=shier cellSpacing=3 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="187" height="154" valign="top"><script src='/showDynamicCustomContent.jsp?id=3'></script></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg><IMG height=43 alt="" src="/images/index_22.jpg" width=39></TD> <TD class=baiheicu width="62%" background=/images/index_24.jpg> <DIV align=center>站长推荐</DIV></TD> <TD class=baiheicu width="19%" background=/images/index_24.jpg> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD vAlign=top bgColor=#ffffff colSpan=2 height=160> <TABLE class=shier cellSpacing=3 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="194" height="154" valign="top"><!--DWLayoutEmptyCell--> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg><IMG height=43 alt="" src="/images/index_22.jpg" width=39></TD> <TD class=baiheicu width="62%" background=/images/index_24.jpg> <DIV align=center></DIV></TD> <TD class=baiheicu width="19%" background=/images/index_24.jpg> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD vAlign=top bgColor=#ffffff colSpan=2 height=150> <TABLE class=shier cellSpacing=3 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="194" height="144" valign="top"><!--DWLayoutEmptyCell--> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg><IMG height=43 alt="" src="/images/index_22.jpg" width=39></TD> <TD class=baiheicu width="62%" background=/images/index_24.jpg> <DIV align=center></DIV></TD> <TD class=baiheicu width="19%" background=/images/index_24.jpg> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD vAlign=top bgColor=#ffffff colSpan=2 height=150> <TABLE class=shier cellSpacing=3 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="194" height="144" valign="top"><!--DWLayoutEmptyCell--> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg><IMG height=43 alt="" src="/images/index_22.jpg" width=39></TD> <TD class=baiheicu width="62%" background=/images/index_24.jpg> <DIV align=center>高手投稿</DIV></TD> <TD class=baiheicu width="19%" background=/images/index_24.jpg> </TD> </TR> </TBODY> </TABLE> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR></TR> </TBODY> </TABLE></TD> </TR> <TR> <TD bgColor=#ffffff colSpan=2 height=152> <TABLE height=147 cellSpacing=3 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD vAlign=top align=middle width="50%" height=141><BR> <A href="mailto:[email protected]"><IMG height=75 alt="" src="/images/index_52.jpg" width=75 border=0></A></TD> <TD class=shier vAlign=top width="50%"><BR> <TABLE class=shier cellSpacing=3 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD>如果您需要在</TD> </TR> <TR> <TD>本站投稿,</TD> </TR> <TR> <TD>请联系我们</TD> </TR> <TR> <TD>(注明投稿)</TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> </TABLE></TD> </TR> </TABLE></TD> <TD vAlign=top colSpan=11> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="5%"><IMG height=29 alt="" src="/images/index_11.jpg" width=32></TD> <TD class=cuzi width="81%" background=/images/index_13.jpg>最新文章</TD> <TD class=shier width="14%" background=/images/index_13.jpg> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=2> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="601" height="48" valign="top"><img src='/images/article_title_pic.gif' alt='普通文章'> <a class='listA' href='/Article/jspjc/2005/11/20051130002605.html' title='CSDN 文档中心:[算法]Java中的位运算优化:位域、位'>CSDN ...</a><br><img src='/images/article_title_pic.gif' alt='普通文章'> <a class='listA' href='/Article/JSPJQ/2005/11/20051129211737.html' title='JSP缓存技术'>JSP缓存...</a><br> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD> <TABLE class=youhei cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neizuo.jpg" width=23></TD> <TD class=cuzi vAlign=center width="74%" background=/images/neibg.jpg>JSP技巧</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=235> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="278" height="227" valign="top"><img src='/images/article_title_pic.gif' alt='普通文章'> <a href='/Article/JSPJQ/2005/11/20051129211737.html'>JSP缓存技术</a><br> </TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=3 height=200> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neizuo.jpg" width=23></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>Struts</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=205> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="278" height="197" valign="top"></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> <TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neili.jpg" width=31></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>JS技巧</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=235> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="291" height="227" valign="top"></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=3 height=200> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neizuo.jpg" width=23></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>Hibernate</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=205> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="306" height="197" valign="top"></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD height=468> <TABLE class=youhei cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neizuo.jpg" width=23></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>JSTL</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=235> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="293" height="227" valign="top"></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=247> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neizuo.jpg" width=23></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>JSP教程</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=220> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="285" height="212" valign="top"><img src='/images/article_title_pic.gif' alt='普通文章'> <a class='listA' href='/Article/jspjc/2005/11/20051130002605.html' title='CSDN 文档中心:[算法]Java中的位运算优化:位域、位'>CSDN 文档中心:...</a><br></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> <TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neili.jpg" width=31></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>EL表达式</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=235> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="277" height="227" valign="top"></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=3 height=230> <TABLE height=0 cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width="2%" background=/images/neibg.jpg><IMG height=29 src="/images/neizuo.jpg" width=23></TD> <TD class=cuzi width="74%" background=/images/neibg.jpg>JSP源码</TD> <TD width="24%" background=/images/neibg.jpg><SPAN class=shier>more...</SPAN></TD> </TR> <TR> <TD vAlign=top colSpan=3 height=220> <TABLE cellSpacing=4 cellPadding=0 width="100%" border=0> <!--DWLayoutTable--> <TBODY> <TR> <TD width="299" height="212" valign="top"></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> </TBODY> </TABLE></TD> </TR> </TABLE></TD> </TR> <TR> <TD colSpan=21> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD background=/images/index_55.jpg><IMG height=98 alt="" src="/images/index_55.jpg" width=23></TD> <TD background=/images/index_55.jpg> <TABLE cellSpacing=3 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> <DIV align=center><IMG title=中国崛起联盟-海外华人组织 height=31 alt=中国崛起 src="/images/logo.jpg" width=88 border=0></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> </TR> <TR> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> <TD> <DIV align=center><IMG height=31 src="/images/logo.jpg" width=88></DIV></TD> </TR> </TBODY> </TABLE></TD> <TD background=/images/index_55.jpg><IMG height=98 alt="" src="/images/index_55.jpg" width=23></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD colSpan=21> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD background=/images/index_57.jpg height=33> <DIV class=shier align=center><A onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(window.location.href);return false" href="http://www.v246.com/">设为首页</A> | 关于本站 | 联系我们 | 隐私条约 | 版权声明 | 网站留言</DIV></TD> </TR> <TR> <TD class=baizi background=/images/index_59.jpg height=56><DIV align=center> <P>版权所有:E鹰网络工作室</P> </DIV></TD> </TR> </TBODY> </TABLE></TD> </TR> <TR> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=9></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=2></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=4></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=9></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=15></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=9></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=38></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=49></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=15></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=49></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=10></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=5></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=13></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=4></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=53></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=9></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=49></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=161></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=212></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=11></TD> <TD><IMG height=1 alt="" src="/images/spacer.gif" width=74></TD> </TR> </TABLE> </TD></TR></TBODY><!-- ImageReady Slices (01 副本.psd) --><!-- End ImageReady Slices --> </BODY></HTML>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值