本站首页    管理页面    写新日志    退出


«October 2025»
1234
567891011
12131415161718
19202122232425
262728293031


公告

戒除浮躁,读好书,交益友


我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:邢红瑞的blog
日志总数:523
评论数量:1142
留言数量:0
访问次数:9722759
建立时间:2004年12月20日




[j2ee]JSTL的几个高级用法
原创空间,  软件技术,  电脑与网络

邢红瑞 发表于 2006/12/28 18:23:49

JSTL的几个高级用法fn函数JSTL1.1标签库还包含了许多其它经常使用的函数: fn:contains(string, substring) 如果参数string中包含参数substring,返回true fn:containsIgnoreCase(string, substring) 如果参数string中包含参数substring(忽略大小写),返回true fn:endsWith(string, suffix) 如果参数 string 以参数suffix结尾,返回true fn:escapeXml(string) 将有特殊意义的XML (和HTML)转换为对应的XML character entity code,并返回 fn:indexOf(string, substring) 返回参数substring在参数string中第一次出现的位置 fn:join(array, separator) 将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。 fn:length(item) 返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。如果是String类型,返回值是String中的字符数。 fn:replace(string, before, after) 返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果 fn:split(string, separator) 返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素 fn:startsWith(string, prefix) 如果参数string以参数prefix开头,返回true fn:substring(string, begin, end) 返回参数string部分字符串, 从参数begin开始到参数end位置,包括end位置的字符 fn:substringAfter(string, substring) 返回参数substring在参数string中后面的那一部分字符串 fn:substringBefore(string, substring) 返回参数substring在参数string中前面的那一部分字符串 fn:toLowerCase(string) 将参数string所有的字符变为小写,并将其返回 fn:toUpperCase(string) 将参数string所有的字符变为大写,并将其返回 fn:trim(string) 去除参数string 首尾的空格,并将其返回  主要是替换<sql:setDataSource var="dataSrc"    url="jdbc:jtds:sqlserver://localhost/LOG_DB" driver="net.sourceforge.jtds.jdbc.Driver"    user="sa" password="admin"/>    <%-- Set number of rows to process --%>    <c:set var="noOfRows" value="100" />    <c:set var="msg" value="select top 100 * from L_ips_tb where id> (select max (id) from (select top ard id from L_ips_tb order by id) as T)     order by id"/> <c:set var="test" value="${fn:replace(msg,'ard',100)}" />  <c:out value="${test}" />    <sql:query var="empList"      sql="${test}"       dataSource="${dataSrc}"    />   <c:out value="${fn:length(empList.rows)}"/> 使用反射<c:setvar="arrayvalue"value="ID,SrcIP"/><c:setvar="delim"value=","/><c:setvar="array"value="${fn:split(arrayvalue,delim)}"/><c:setvar="count"value="${fn:length(array)}"/> array是一个String数组,loghistory是一个Map <c:forEachvar="loghistory"items="${loghistory}"varStatus="statusindex"> <c:forEachbegin="0"end="${count-1}""varStatus="index"><c:outvalue="${loghistory[array[index.index]]}"/></c:forEach><c:choose>使用二维数组<c:forEach items="${applicationScope[param.answersMapName]}"          var="a">          ${a.key}) ${a.value}:           ${applicationScope[param.votesMapName][a.key]}<br>        </c:forEach〉


阅读全文(5545) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.695 second(s), page refreshed 144797021 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号