发布于 2015-08-17 14:50:52 | 100 次阅读 | 评论: 0 | 来源: 网络整理

fn:length() 函数返回字符串的长度或集合中的项目数。

语法

 fn:length()函数具有以下语法:


int length(java.lang.Object)

例子:

下面是例子来说明这个函数的功能:


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
<title>Using JSTL Functions</title>
</head>
<body>

<c:set var="string1" value="This is first String."/>
<c:set var="string2" value="This is second String." />

<p>Length of String (1) : ${fn:length(string1)}</p>
<p>Length of String (2) : ${fn:length(string2)}</p>

</body>
</html>

这将产生以下输出结果:


Length of String (1) : 21
Length of String (2) : 22
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务