首页 > 代码库 > 总结-EL表达式

总结-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 字符串连接

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

2 split

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

3 length

    ${fn:length("abc")}

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

4 substring

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

5 contains

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

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

6 replace

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

总结-EL表达式