EL函数库(由JSTL提供的)
* 导入标签库:<%@ tablib prefix="fn" uri="http://java.sun.com/jsp/jstl/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):联合字符串数组!
下面是例子:
1 <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 2 … 3 String[] strs = {"a", "b","c"}; 4 List list = new ArrayList(); 5 list.add("a"); 6 pageContext.setAttribute("arr", strs); 7 pageContext.setAttribute("list", list); 8 %> 9 ${fn:length(arr) }<br/><!--3--> 10 ${fn:length(list) }<br/><!--1--> 11 ${fn:toLowerCase("Hello") }<br/> <!-- hello --> 12 ${fn:toUpperCase("Hello") }<br/> <!-- HELLO --> 13 ${fn:contains("abc", "a")}<br/><!-- true --> 14 ${fn:containsIgnoreCase("abc", "Ab")}<br/><!-- true --> 15 ${fn:contains(arr, "a")}<br/><!-- true --> 16 ${fn:containsIgnoreCase(list, "A")}<br/><!-- true --> 17 ${fn:endsWith("Hello.java", ".java")}<br/><!-- true --> 18 ${fn:startsWith("Hello.java", "Hell")}<br/><!-- true --> 19 ${fn:indexOf("Hello-World", "-")}<br/><!-- 5 --> 20 ${fn:join(arr, ";")}<br/><!-- a;b;c --> 21 ${fn:replace("Hello-World", "-", "+")}<br/><!-- Hello+World --> 22 ${fn:join(fn:split("a;b;c;", ";"), "-")}<br/><!-- a-b-c --> 23 24 ${fn:substring("0123456789", 6, 9)}<br/><!-- 678 --> 25 ${fn:substring("0123456789", 5, -1)}<br/><!-- 56789 --> 26 ${fn:substringAfter("Hello-World", "-")}<br/><!-- World --> 27 ${fn:substringBefore("Hello-World", "-")}<br/><!-- Hello --> 28 ${fn:trim(" a b c ")}<br/><!-- a b c --> 29 ${fn:escapeXml("<html></html>")}<br/> <!-- <html></html> -->