JSP之JSTL_functions
<?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0"> <description>JSTL 1.1 functions library</description>
<display-name>JSTL functions</display-name>
<tlib-version>1.1</tlib-version>
<short-name>fn</short-name>
<uri>http://java.sun.com/jsp/jstl/functions</uri> <function>
<description>
Tests if an input string contains the specified substring.
</description>
<name>contains</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean contains(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:contains(name, searchString)}">
</example>
</function> <function>
<description>
Tests if an input string contains the specified substring in a case insensitive way.
</description>
<name>containsIgnoreCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean containsIgnoreCase(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:containsIgnoreCase(name, searchString)}">
</example>
</function> <function>
<description>
Tests if an input string ends with the specified suffix.
</description>
<name>endsWith</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean endsWith(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:endsWith(filename, ".txt")}">
</example>
</function> <function>
<description>
Escapes characters that could be interpreted as XML markup.
</description>
<name>escapeXml</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String escapeXml(java.lang.String)</function-signature>
<example>
${fn:escapeXml(param:info)}
</example>
</function> <function>
<description>
Returns the index withing a string of the first occurrence of a specified substring.
</description>
<name>indexOf</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>int indexOf(java.lang.String, java.lang.String)</function-signature>
<example>
${fn:indexOf(name, "-")}
</example>
</function> <function>
<description>
Joins all elements of an array into a string.
</description>
<name>join</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String join(java.lang.String[], java.lang.String)</function-signature>
<example>
${fn:join(array, ";")}
</example>
</function> <function>
<description>
Returns the number of items in a collection, or the number of characters in a string.
</description>
<name>length</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>int length(java.lang.Object)</function-signature>
<example>
You have ${fn:length(shoppingCart.products)} in your shopping cart.
</example>
</function> <function>
<description>
Returns a string resulting from replacing in an input string all occurrences
of a "before" string into an "after" substring.
</description>
<name>replace</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String replace(java.lang.String, java.lang.String, java.lang.String)</function-signature>
<example>
${fn:replace(text, "-", "")}
</example>
</function> <function>
<description>
Splits a string into an array of substrings.
</description>
<name>split</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String[] split(java.lang.String, java.lang.String)</function-signature>
<example>
${fn:split(customerNames, ";")}
</example>
</function> <function>
<description>
Tests if an input string starts with the specified prefix.
</description>
<name>startsWith</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean startsWith(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:startsWith(product.id, "100-")}">
</example>
</function> <function>
<description>
Returns a subset of a string.
</description>
<name>substring</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substring(java.lang.String, int, int)</function-signature>
<example>
P.O. Box: ${fn:substring(zip, 6, -1)}
</example>
</function> <function>
<description>
Returns a subset of a string following a specific substring.
</description>
<name>substringAfter</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substringAfter(java.lang.String, java.lang.String)</function-signature>
<example>
P.O. Box: ${fn:substringAfter(zip, "-")}
</example>
</function> <function>
<description>
Returns a subset of a string before a specific substring.
</description>
<name>substringBefore</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substringBefore(java.lang.String, java.lang.String)</function-signature>
<example>
Zip (without P.O. Box): ${fn:substringBefore(zip, "-")}
</example>
</function> <function>
<description>
Converts all of the characters of a string to lower case.
</description>
<name>toLowerCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String toLowerCase(java.lang.String)</function-signature>
<example>
Product name: ${fn:toLowerCase(product.name)}
</example>
</function> <function>
<description>
Converts all of the characters of a string to upper case.
</description>
<name>toUpperCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String toUpperCase(java.lang.String)</function-signature>
<example>
Product name: ${fn:UpperCase(product.name)}
</example>
</function> <function>
<description>
Removes white spaces from both ends of a string.
</description>
<name>trim</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String trim(java.lang.String)</function-signature>
<example>
Name: ${fn:trim(name)}
</example>
</function> </taglib>
使用方法
上述是http://java.sun.com/jsp/jstl/functions的源代码 用来弥补JSTL在处理字符串上的缺陷 使用的方式 一、 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 二、 在WEB-INF目录下创建functions.ltd 然后将上述代码拷进去 <%@ taglib prefix="fn" uri="/WEB-INF/functions.tld" %> 或则 <%@ 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表示,例如<字符应该转为< ${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, "-", "")}
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)}
JSP之JSTL_functions的更多相关文章
- myeclipse学习总结一(在MyEclipse中设置生成jsp页面时默认编码为utf-8编码)
1.每次我们在MyEclispe中创建Jsp页面,生成的Jsp页面的默认编码是"ISO-8859-1".在这种情况下,当我们在页面中编写的内容存在中文的时候,就无法进行保存.如下图 ...
- jsp前端实现分页代码
前端需要订一page类包装,其参数为 private Integer pageSize=10; //每页记录条数=10 private Integer totalCount; //总记录条数 priv ...
- jsp中出现onclick函数提示Cannot return from outside a function or method
在使用Myeclipse10部署完项目后,原先不出错的项目,会有红色的叉叉,JSP页面会提示onclick函数错误 Cannot return from outside a function or m ...
- jsp页面无法识别el表达式的解决方案
今天在写一个springmvc的小demo时,碰到一个问题,在jsp页面中书写为${user.username}的表达式语言,在浏览器页面中仍然显示为${user.username},说明jsp根本不 ...
- 浅谈JSP中include指令与include动作标识的区别
JSP中主要包含三大指令,分别是page,include,taglib.本篇主要提及include指令. include指令使用格式:<%@ include file="文件的绝对路径 ...
- 浅谈JSP注释
HTML注释 JSP文件是由HTML尿急和嵌入的Java程序片段组成的,所以在HTML中的注释同样可以在JSP文件中使用.注释格式:<!--注释内容--> <!-- 欢迎提示信息! ...
- JSP 标准标签库(JSTL)
JSP 标准标签库(JSTL) JSP标准标签库(JSTL)是一个JSP标签集合,它封装了JSP应用的通用核心功能. JSTL支持通用的.结构化的任务,比如迭代,条件判断,XML文档操作,国际化标签, ...
- Nginx服务器之Nginx与tomcat结合访问jsp
本文使用linux centos系统 本文概述: JSP是一种动态网页技术标准.使用的方式是在HTML文件中插入程序段和JSP标记,而形成JSP文件.使用JSP开发WEB应用可以跨平台开发.但jsp需 ...
- 基于jsp+servlet图书管理系统之后台万能模板
前奏: 刚开始接触博客园写博客,就是写写平时学的基础知识,慢慢发现大神写的博客思路很清晰,知识很丰富,非常又价值,反思自己写的,顿时感觉非常low,有相当长一段时间没有分享自己的知识.于是静下心来钻研 ...
随机推荐
- http协议【转】
HTTP协议详解 当今web程序的开发技术真是百家争鸣,ASP.NET, PHP, JSP,Perl, AJAX 等等. 无论Web技术在未来如何发展,理解Web程序之间通信的基本协议相当重要, 因为 ...
- 常用数学符号的 LaTeX 表示方法
常用数学符号的 LaTeX 表示方法 (以下内容主要摘自"一份不太简短的 LATEX2e 介绍") 1.指数和下标可以用^和_后加相应字符来实现.比如: 2.平方根(square ...
- CSS(三)背景 list-style display visibility opacity vertical cursor
背景background 1.background-color:'' 背景颜色 2.background-image:'' 背景图片 background-repeat:'' 背景图片是否平铺 取 ...
- 快速开发基于 HTML5 网络拓扑图应用--入门篇(二)
上一篇我们绘制了一个 graphView 场景,在场景之上通过 graphView.dm() 获取数据容器,并通过 graphView.dm().add() 函数添加了两个 Node 节点,并通过 s ...
- 由浅入深SCF无服务器云函数实践
欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 作者:陈杰,腾讯云架构平台部技术专家 近年来,互联网服务从一开始的物理服务器托管,虚拟机,容器,发展到现在的云函数,逐步无服务器化,如下表所示. ...
- Grafana最新版本4.3.1安装(后端使用mysql)
环境 CentOS release 6.5 (Final) 64bitzabbix_server (Zabbix) 3.0.3 grafana-4.3.1mysql-5.6.21 一.安装grafan ...
- JS高级代码
JS 的defineProperties 设置多个属性 var book = {}; //用Object.defineProperties()方法设置多个属性 Object.definePropert ...
- bzoj 3874: [Ahoi2014]宅男计划
Description [故事背景] 自从迷上了拼图,JYY就变成了个彻底的宅男.为了解决温饱问题,JYY 不得不依靠叫外卖来维持生计. [问题描述] 外卖店一共有N种食物,分别有1到N编号.第i种 ...
- [51nod1297]管理二叉树
一个初始为空的二叉搜索树T,以及1到N的一个排列P: {a1, a2, ..., aN}.我们向这个二叉搜索树T添加这些数,从a1开始, 接下来是 a2, ..., 以aN结束.在每一个添加操作后,输 ...
- POJ 1659 Frogs' Neighborhood(可图性判定—Havel-Hakimi定理)【超详解】
Frogs' Neighborhood Time Limit: 5000MS Memory Limit: 10000K Total Submissions: 9897 Accepted: 41 ...