JSTL(fn函数)

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

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

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

fn:contains(string, substring)

假如参数string中包含参数substring,返回true

例如:<c:if test="${fn:contains(name, searchString)}">

fn:containsIgnoreCase(string, substring)

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

例如:<c:if test="${fn:containsIgnoreCase(name, searchString)}">

fn:endsWith(string, suffix)

假如参数 string 以参数suffix结尾,返回true

例如:<c:if test="${fn:endsWith(filename, ".txt")}">

fn:escapeXml(string)

将有非凡意义的XML (和HTML)转换为对应的XML character entity code,并返回

例如: <字符应该转为&lt; ${fn:escapeXml(param:info)}

fn:indexOf(string, substring)

返回参数substring在参数string中第一次出现的位置

${fn:indexOf(name, "-")}

fn:join(array, separator)

将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。

${fn:join(array, ";")}

fn:length(item)

返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。假如是String类型,返回值是String中的字符数。

${fn:length(shoppingCart.products)}

fn:replace(string, before, after)

返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果

${fn:replace(text, "-", "•")}

fn:split(string, separator)

返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素

${fn:split(customerNames, ";")}

fn:startsWith(string, prefix)

假如参数string以参数prefix开头,返回true

<c:if test="${fn:startsWith(product.id, "100-")}">

fn:substring(string, begin, end)

返回参数string部分字符串,从参数begin开始到参数end位置,包括end位置的字符

${fn:substring(zip, 6, -1)}

fn:substringAfter(string, substring)

返回参数substring在参数string中后面的那一部分字符串

${fn:substringAfter(zip, "-")}

fn:substringBefore(string, substring)

返回参数substring在参数string中前面的那一部分字符串

${fn:substringBefore(zip, "-")}

fn:toLowerCase(string)

将参数string所有的字符变为小写,并将其返回

${fn.toLowerCase(product.name)}

fn:toUpperCase(string)

将参数string所有的字符变为大写,并将其返回

${fn.UpperCase(product.name)}

fn:trim(string)

去除参数string 首尾的空格,并将其返回

${fn.trim(name)}

下面是一个在页面显示时超过100个字符以后用......代替的方法:

JSTL(fn函数)的更多相关文章

  1. 自定义jstl fn函数fns

    1.引入函数声明: jsp页面需要引入自定义fns函数声明:<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld&q ...

  2. JSTL fn:split()函数

    jstl fn:split()函数代码和用法 -使用fn:split() 函数将一个字符串到一个数组根据分隔符字符串的子字符串. 使用fn:split() 函数将一个字符串到一个数组根据分隔符字符串的 ...

  3. EL表达式中fn函数 (转载)

    JSTL 使用表达式来简化页面的代码,这对一些标准的方法,例如bean的getter/setter方法,请求参数或者context以及 session中的数据的访问非常方便,但是我们在实际应用中经常需 ...

  4. EL表达式中fn函数

    JSTL 使用表达式来简化页面的代码,这对一些标准的方法,例如bean的getter/setter方法,请求参数或者context以及 session中的数据的访问非常方便,但是我们在实际应用中经常需 ...

  5. jstl fn:replace替换换行符

    textarea输入换行符后应该是'\n',在div中展示时替换成'<br>' 找到一种方法用jsp标签 jstl fn:replace方法 使用fn:replace方法之前 先要把jst ...

  6. 关于thenao.scan() fn函数参数的说明

    theano.scan()原型: theano.scan( fn, sequences=None, outputs_info=None, non_sequences=None, n_steps=Non ...

  7. jQuery-使用hover(fn,fn)函数监听mouseover和mouseout两个事件

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  8. JSTL的fn函数

    JSTL使用表达式来简化页面的代码,这对一些标准的方法,例如bean的getter/setter方法,请求参数或者context以及session中的数据的访问非常方便,但是我们在实际应用中经常需要在 ...

  9. JSTL fn:contains()函数

    fn:contains() 函数判断一个输入字符串是否包含一个指定的子串. 语法 使用 fn:contains() 函数具有以下语法: boolean contains(java.lang.Strin ...

随机推荐

  1. Project Euler 101 :Optimum polynomial 最优多项式

    Optimum polynomial If we are presented with the first k terms of a sequence it is impossible to say ...

  2. MSChart 控件

    微软发布了.NET 3.5框架下的图表控件,功能很强劲,基本上能想到的图表都可以使用它绘制出来,给图形统计和报表图形显示提供了很好的解决办法,同时支持Web和WinForm两种方式,不过缺点也比较明显 ...

  3. Java:包的使用Pack

    在包A中创建一个类并在类中定义一个方法 package packA; public class PackDemoA { public void show() { System.out.println( ...

  4. Linux命令-wc

    wc命令用于统计指定文本的行数.字数.字节数 格式:wc [参数] 文本 [root@localhost test]# wc test.txt test.txt [root@localhost tes ...

  5. Windows下搭建Android开发环境

    1.下载eclipse google eclipse,到官网去下载最新版的,推荐java ee版本的,当然你要用android版本或者standard也无妨 2.下载android sdk,安装相关的 ...

  6. 动态库加载出错,cannot restore segment prot after reloc: Permission denied

    转自:taolinke的博客 项目中碰到的问题,编译好的so文件,放到其他机器上去加载,报了错误,cannot restore segment prot after reloc: Permission ...

  7. 局部敏感哈希Locality Sensitive Hashing(LSH)之随机投影法

    1. 概述 LSH是由文献[1]提出的一种用于高效求解最近邻搜索问题的Hash算法.LSH算法的基本思想是利用一个hash函数把集合中的元素映射成hash值,使得相似度越高的元素hash值相等的概率也 ...

  8. jQuery练习一好友列表变色

    多选 选中变色 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  9. 第7篇 ORACLE EBS DEMO虚拟机环境的安装

    ERP信息系统的实施不仅要求懂得道理方面的知识,更要侧重于应用实践.为了有一个稳定的测试环境.初学者可以自己搭建一个EBS DEMO环境.本节介绍EBS DEMO环境虚拟机的安装.一. 安装前的准备( ...

  10. [51NOD1127]最短的包含字符串(尺取法)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1127 思路:尺取法,一开始我考虑更新右指针,直到遇到一个和l指 ...