EL 函数库|学习笔记

开发者学堂课程【JSP 快速入门 EL 函数库】学习笔记,与课程紧密联系,让用户快速学习知识。

课程地址:https://developer.aliyun.com/learning/course/33/detail/729


EL 函数库


导入标签库:

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

string toUppercase (String input):把参数转换成大写

String toLowercase (String input):把参数转换成小写

int indexOf(String input,String substring):从大串,输出小串的位置

boolean contains(String input,String substring):查看大串中是否包含小串

boolean containsIgnoreCase(String input,String substring):忽略大小写的,是否包含

boolean startsWith(String input,string substring):是否以小串为前缀

boolean endsWith(String input,String substring):+是否以小串为后缀

String substring (String input,int beginIndex,int endIndex):截取子串

String substringAfter(String input,String substring):获取大串中,小串所在位置后面的字符串substringBefore(String input,String substring):获取大串中,小串所在位置前面的字符串

string escapeXml(String input):把input中"<"、">"、"&"、"'"、""",进行转义

string trim (String input) :去除前后空格

String replace(String input,String substringBefore,String substringAfter):替换

String[] split(String input,String delimiters):分割字符串,得到字符串数组

int length(Object obj):可以获取字符串、数组、各种集合的长度

String join(String array[],String separator):联合字符串数组

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

string [ ] strs= { "a","b","c"};

List list= new ArrayList();

List.add ( "a") ;

pageContext.setAttribute ("arr";strs);

pagaContext.setAttxibute ("list",list) ;

%>

$ {fn:length (arr)}<br/><!--3-->

$ {fn:length (list) }<br/><!--1-->

$ {fn;.toLowexCase("Hello") }<br/> <!-- hello -->

$ {fn:toUppercaae ( "Hello") }<br/ > <!-- HELLO-->

$ {fn:.contains("abc","a") }<br/><!-- true -->

$ {fn:.containsIgnoreCase ("abc","Ab" ) }<br/ ><!-- true -->

$ {fn:contains(arr, "a") }<br/><!-- true -->

${fn:containsIganoreCase(list,"A")}<br/><!--true-->

${fn:endsWith("Hello.java",".java")}<br/><!--true-->

${fn:startsWith("Hello.java"."Hell")}<br,/><!--true -->

$ {fn:indexOf ( "Hello-world","-") }<br/ ><!-- 5-->

$ { fn:.indexof("Hello-World" ,"-") }<bx/ ><!-- 5 -->

$ { fn:join(arr,"; ")}<bx/><!—a;b;c-->

$ { fn:replace ("Hello-World","-","+")}<br/><!—Hallo+World-->

$ { fn:join(fn:split("a;b;c;","; "),"-")}<br/><!-- a-b-c -->

$ { fn:substring("0123456789",6,9)}<br/><!--678-->

$ { fn:substring("0123456789",5,-1)}<bx/><!-- 56789 -->

${fn:substringAftex ( "Hello-World","-")}<br/><!-- World -->

$ { fn:substringBefore( "Hello-world","-")}<br/><!-- Hello -->

$ { fn.trim ("a b c") }<br/ ><!-- a b c -->

$ { fn:escapeXml ( "<html></html>") }<br/><!-- <html></html> -->

上一篇:解决小程序云函数操作数据库回调不执行


下一篇:JS-制作可伸缩的水平菜单栏