JSP标签JSTL(5)--常用的标签函数

来源:互联网 发布:淘宝2017年双十一 编辑:程序博客网 时间:2024/05/29 19:47

在使用JSTL的标签函数的时候请务必加上如下代码

<!-- 添加jsp标签的核心库 --><%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>    

否则是没有办法使用到这些函数的。


常用的JSTL函数释义


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

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

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

fn:contains(string, substring)
假如参数string中包含参数substring,返回true
例如:

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

fn:endsWith(string, suffix)
假如参数 string 以参数suffix结尾,返回true
例如:

<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>
0 0
原创粉丝点击