${fn:} 函数
调用这样一个头文件<%@ 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)}
函数描述
- fn:contains(string, substring) 如果参数string中包含参数substring,返回true
- fn:containsIgnoreCase(string, substring)
如果参数string中包含参数substring(忽略大小写),返回true - fn:endsWith(string, suffix) 如果参数 string 以参数suffix结尾,返回true
- fn:escapeXml(string) 将有特殊意义的XML (和HTML)转换为对应的XML character entity
code,并返回 - fn:indexOf(string, substring) 返回参数substring在参数string中第一次出现的位置
- fn:join(array, separator)
将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。 - fn:length(item)
返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。如果是String类型,返回值是String中的
字符数。 - fn:replace(string, before, after)
返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果 - fn:split(string, separator) 返回一个数组,以参数separator
为分割符分割参数string,分割后的每一部分就是数组的一个元素 - fn:startsWith(string, prefix) 如果参数string以参数prefix开头,返回true
- fn:substring(string, begin, end) 返回参数string部分字符串,
从参数begin开始到参数end位置,包括end位置的字符 - fn:substringAfter(string, substring)
返回参数substring在参数string中后面的那一部分字符串 - fn:substringBefore(string, substring)
返回参数substring在参数string中前面的那一部分字符串 - fn:toLowerCase(string) 将参数string所有的字符变为小写,并将其返回
- fn:toUpperCase(string) 将参数string所有的字符变为大写,并将其返回
- fn:trim(string) 去除参数string 首尾的空格
,并将其返回
随机推荐
- 关于android上dpi/screen-size的厘清解释
android定义了四种screen-size: small normal large xlarge 同时定义了六种dpi级别: ldpi (low) ~120dpimdpi (medium) ~16 ...
- 《精通Spring4.X企业应用开发实战》读后感第六章(国际化)
- Java学习之多态(Polymorphism)
多态==晚绑定 不要把函数重载理解为多态. 因为多态是一种运行期的行为,不是编译期的行为. 多态:父类型的引用可以指向子类型的对象. 比如 Parent p = new Child(); 当使用多态方 ...
- 23. Bypass ngx_lua_waf SQL注入防御(多姿势)
0x00 前言 ngx_lua_waf是一款基于ngx_lua的web应用防火墙,使用简单,高性能.轻量级.默认防御规则在wafconf目录中,摘录几条核心的SQL注入防御规则: select.+(f ...
- OC官方文档翻译-Values-and-Collections-值与集合类型
查看全部文档翻译,请浏览https://github.com/L1l1thLY/Programming-with-Objective-C-in-Chinese,blog仅收录本人翻译的两章. 简述 O ...
- Boost Python学习笔记(四)
你将学到什么 在Python中调用C++代码时的传参问题 基础类型 Python的字符串是常量,所以C++函数参数中的std::string &必须为const 修改源文件(main.cpp) ...
- bootstrap初学者模板
<!doctype html> <html lang="en"> <head> <!-- Required meta tags --> ...
- springIOC源码解析之BeanDefinition的注册
ApplicationContext类结构 context是一个存储上下文结构的东西,里面会引用BeanFactory BeanFactory类结构 我们从这句代码开始分析,(本文spring采用的 ...
- spring使用redisTemplate
连接工厂:spring data redis 2.0中提供了两种redis客户端实现 LettuceConnectionFactory JedisConnectionFactory 区别: Lettu ...
- Shell面试,笔试整理
1.经典Shell脚本面试问题:https://blog.csdn.net/hyszyl/article/details/60970307