常用的JSTL函数

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
函数名   函数说明   使用举例 
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)} 

  

posted @   codingcloud  阅读(1181)  评论(1编辑  收藏  举报
编辑推荐:
· ASP.NET Core 模型验证消息的本地化新姿势
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
阅读排行:
· dotnet 源代码生成器分析器入门
· 官方的 MCP C# SDK:csharp-sdk
· 从零开始:基于 PyTorch 的图像分类模型
· [WPF] 在RichTextBox中输出Microsoft.Extension.Logging库的
· 一步一步教你部署ktransformers,大内存单显卡用上Deepseek-R1
点击右上角即可分享
微信分享提示