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,有相当长一段时间没有分享自己的知识.于是静下心来钻研 ...
随机推荐
- 【Python3之字符编码】
一.字符集和字符编码 1.定义 计算机中储存的信息都是用二进制数表示的,而我们在屏幕上看到的英文.汉字等字符是二进制数转换之后的结果.通俗的说,按照何种规则将字符存储在计算机中,如'a'用什么表示,称 ...
- QuickStart系列:docker部署之Elasticsearch
ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch是用Java开发的,并作为Apach ...
- OpenCV探索之路(四):膨胀、腐蚀、开闭运算
腐蚀和膨胀是最基本的形态学运算. 腐蚀和膨胀是针对白色部分(高亮部分)而言的. 膨胀就是对图像高亮部分进行"领域扩张",效果图拥有比原图更大的高亮区域:腐蚀是原图中的高亮区域被蚕食 ...
- 【Tarjan缩点】POJ2186 Popular Cows
Popular Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 35644 Accepted: 14532 De ...
- [转载]常见slave 延迟原因以及解决方法
一 序言在运维线上M-M 架构的MySQL数据库时,接收的比较多关于主备延时的报警: 点击(此处)折叠或打开 check_ins_slave_lag (err_cnt:1)critical-slav ...
- CSS根据子元素个数不同定义样式
近日面试,遇见了一个这样的问题,不会,便记下来. 问题:如何根据子元素个数的不同定义不同的样式? 代码:HTML <ul> <li>1</li> <li> ...
- kmalloc、vmalloc、__get_free_pages()的区别
一.分布位置上的区别: kmalloc()和__get_free_pages()函数申请的内存位于物理内存的映射区域,而且在物理上也是连续的,它们与真实的物理地址只有一个固定的偏移,因此存在简单的线性 ...
- Keepalived概述和安装(1)
一.Keepalived概述 本文主要了解开源高可用负载均衡集群利器keepalived,掌握keepalived的安装,运用keepalived配置高可用集群,并能够实现keepalived与负载均 ...
- Scrapy运行错误:ImportError: No module named win32api
需要安装pypiwin32,直接通过官网安装exe会出现很多错误,所以直接运行以下命令: pip install pypiwin32
- django笔记整理
Django复习: MTV模型: manager启动服务→urls找到路径→(找到views视图函数或者做路由分发)→视图函数处理相关逻辑,返回一个模板或者是字符串: ---------------- ...