Home > Web Front-end > JS Tutorial > Detailed explanation of function examples for intercepting strings using EL expressions

Detailed explanation of function examples for intercepting strings using EL expressions

小云云
Release: 2018-02-03 13:25:13
Original
1632 people have browsed it

This article mainly introduces the function description of EL expression to intercept strings. At the bottom of the article, I introduce to you the list of methods and their descriptions that come with JSTL. Friends who need it can refer to it. I hope it can help you.

Introducing the tag library

<%@tablib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
${fn:substring("你要截取的字符串"),beginIndex,endIndex}
Copy after login

The following is a list of methods in JSTL and their descriptions

Function name function description usage example

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)}
Copy after login

Related recommendations:

A collection of commonly used methods for intercepting strings in JS

Solution to the problem of Chinese garbled characters when intercepting strings in php

Usage difference analysis of three common ways to intercept strings in javascript

The above is the detailed content of Detailed explanation of function examples for intercepting strings using EL expressions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template