EL表达式各种函数使用大全

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

函数名函数说明使用举例
fn:contains判断字符串是否包含另外一个字符串<c:if test="${fn:contains(name, searchString)}">
fn:containsIgnoreCase判断字符串是否包含另外一个字符串(大小写无关)<c:if test="${fn:containsIgnoreCase(name, searchString)}">
fn:endsWith判断字符串是否以另外字符串结束<c:if test="${fn:endsWith(filename, ".txt")}">
fn:escapeXml把一些字符转成XML表示,例如<字符应该转为&lt;${fn:escapeXml(param:info)}
fn:indexOf子字符串在母字符串中出现的位置${fn:indexOf(name, "-")}
fn:join将数组中的数据联合成一个新字符串,并使用指定字符格开${fn:join(array, ";")}
fn:length获取字符串的长度,或者数组的大小${fn:length(shoppingCart.products)}
fn:replace替换字符串中指定的字符${fn:replace(text, "-", "&#149;")}
fn:split把字符串按照指定字符切分${fn:split(customerNames, ";")}
fn:startsWith判断字符串是否以某个子串开始<c:if test="${fn:startsWith(product.id, "100-")}">
fn:substring获取子串${fn:substring(zip, 6, -1)}
fn:substringAfter

获取从某个字符所在位置开始的子串

${fn:substringAfter(zip, "-")}
fn:substringBefore获取从开始到某个字符所在位置的子串${fn:substringBefore(zip, "-")}
fn:toLowerCase转为小写${fn.toLowerCase(product.name)}
fn:toUpperCase转为大写字符${fn.UpperCase(product.name)}
fn:trim去除字符串前后的空格${fn.trim(name)}

 

JSTL中<c:if>标签没有对应的else因此采用

<c:choose> 

     <c:when test="">    <!--如果 --> 

 </c:when>      

     <c:otherwise>  <!--否则 -->    

  </c:otherwise> 

</c:choose>

 

另外:el判断关键字:

eq相等 ne、neq不相等, 
gt大于, lt小于 
gt大于, lt小于 
gte、ge大于等于   
lte、le 小于等于   
not非   mod求模   
is [not] div by是否能被某数整除   
is [not] even是否为偶数   
is [not] even by $b即($a / $b) % 2 == 0   
is [not] odd是否为奇   
is not odd by $b即($a / $b) % 2 != 0 
示例: 
equal/ not equal/ greater than/ less than/ less than or equal/ great than or equal/后面的就不用说了 

转载于:https://my.oschina.net/iyinghui/blog/2048668

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值