StevenBot-Saltsam

眼睛能装下世界,为何却装不下眼泪? 一只风筝一辈子只为一根线冒险。 那不是一场游戏,为何总有一根线牵着心怀,隐隐作疼? 那不是一段邂逅,为何飘在桥上的影子,总缠进梦乡? 那不是一个梦境,为何你的温柔私语,总是不经意的响起?

导航

<2011年10月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

统计

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

datas link

OSChinal Sources codes Library

搜索

最新评论

阅读排行榜

评论排行榜

JSTL(fn)

首先,我们要在页面的最上方引用:

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

 

下面是JSTL中自带的方法列表以及其描述 

 

fn:contains(string, substring)

假如参数string中包含参数substring,返回true

例如:<c:if test="${fn:contains(name, searchString)}">

 

fn:containsIgnoreCase(string, substring)

假如参数string中包含参数substring(忽略大小写),返回true

例如:<c:if test="${fn:containsIgnoreCase(name, searchString)}">

 

fn:endsWith(string, suffix)

假如参数 string 以参数suffix结尾,返回true

例如:<c:if test="${fn:endsWith(filename, ".txt")}">

 

fn:escapeXml(string)

将有非凡意义的XML (HTML)转换为对应的XML character entity code,并返回

例如: <字符应该转为&lt; ${fn:escapeXml(param:info)}

 

fn:indexOf(string, substring)

返回参数substring在参数string中第一次出现的位置

${fn:indexOf(name, "-")}

 

fn:join(array, separator)

将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。

${fn:join(array, ";")}

 

fn:length(item)

返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。假如是String类型,返回值是String中的字符数。

${fn:length(shoppingCart.products)}

 

fn:replace(string, before, after)

返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果

${fn:replace(text, "-", "•")}

 

fn:split(string, separator)

返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素

${fn:split(customerNames, ";")}

 

fn:startsWith(string, prefix)

假如参数string以参数prefix开头,返回true

<c:if test="${fn:startsWith(product.id, "100-")}">

 

fn:substring(string, begin, end)

返回参数string部分字符串从参数begin开始到参数end位置,包括end位置的字符

${fn:substring(zip, 6, -1)}

 

fn:substringAfter(string, substring)

返回参数substring在参数string中后面的那一部分字符串

${fn:substringAfter(zip, "-")}

 

fn:substringBefore(string, substring)

返回参数substring在参数string中前面的那一部分字符串

${fn:substringBefore(zip, "-")}

 

fn:toLowerCase(string)

将参数string所有的字符变为小写,并将其返回

${fn.toLowerCase(product.name)}

 

fn:toUpperCase(string)

将参数string所有的字符变为大写,并将其返回

${fn.UpperCase(product.name)}

 

fn:trim(string)

去除参数string 首尾的空格,并将其返回

${fn.trim(name)}

 

 下面是一个在页面显示时超过100个字符以后用......代替的方法:

<c:set var="testStr" value="${analyze.command}" />

              <c:choose>

                   <c:when test="${fn:length(testStr) > 100}">

                      <c:out value="${fn:substring(testStr, 0, 100)}" />  ......

                   </c:when>

                   <c:otherwise>

                      <c:out value="${testStr}" />

                   </c:otherwise>

              </c:choose>

posted on 2011-10-07 15:46 Steven_bot 阅读(501) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: