总结-EL表达式

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

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

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


1 字符串连接(El表达式 字符连接)

    ${"abc".concat("123")}

2 split(El表达式 split)

    <c:forEach items="${fn:split('1,2,3', ',')}" var="str"></c:forEach>

3 length(El表达式 length)

    ${fn:length("abc")}

    ${fn:length(fn:split("a,b,c", ","))}

4 substring(EL表达式 substring)

    ${fn:substring("abc", 0, fn:length("abc"))}

5 contains(EL表达式 contains)

    ${fn:contains("abc", "a")} (containsIgnoreCase)

    不能用于数组、集合(用于数组、集合时,会用对象toString后的字符串来比较,显然不准确)

6 replace(EL表达式 replace)

    ${fn:replace("abbc", "b", "B")}

7 数值表达式为空时,显示 0(EL数值表达式为空时,显示 0)

    ${params.datas.totalCount + 0} // 此处的 + 0 用的非常妙

原文地址:https://www.cnblogs.com/liaolongjun/p/6061653.html