• (3)JSTL的fn方法库


    fn:functions,fn之所以称之为方法库,是因为fn使用不像core,fmt标签那样遵循<prefix:tagName>的格式,而是遵循fn:methodName()的格式

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

    1、fn:contains(string, substring) 
    如果参数string中包含参数substring,返回true。
     

    2、fn:containsIgnoreCase(string, substring) 
    如果参数string中包含参数substring(忽略大小写),返回true
     

    3、fn:endsWith(string, suffix) 
    如果参数 string 以参数suffix结尾,返回true。
     

    4、fn:escapeXml(string) 
    将有特殊意义的XML (和HTML)转换为对应的XML character entity code,并返回。

    5、fn:indexOf(string, substring) 
    返回参数substring在参数string中第一次出现的位置。
     

    6、fn:join(array, separator) 
    将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。
     

    7、fn:length(item) 
    返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。如果是String类型,返回值是String中的字符数。

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

    9、fn:startsWith(string, prefix) 
    如果参数string以参数prefix开头,返回true。
     

    10、fn:substring(string, begin, end) 
    返回参数string部分字符串, 从参数begin开始到参数end位置。
     

    11、fn:substringAfter(string, substring) 
    返回参数substring在参数string中后面的那一部分字符串。
     

    12、fn:substringBefore(string, substring) 
    返回参数substring在参数string中前面的那一部分字符串。
     

    13、fn:toLowerCase(string) 
    将参数string所有的字符变为小写,并将其返回。
     

    14、fn:toUpperCase(string) 
    将参数string所有的字符变为大写,并将其返回。
     

    15、fn:trim(string) 
    去除参数string 首尾的空格,并将其返回。

        <body>       
            <%
                String a[] = {"aa","bb","cc","dd"};
                request.setAttribute("array",a);
                request.setAttribute("store","guomei8899");
            %> 
            <c:if test="${fn:contains('guomeiddd','guoMei')}">ok</c:if><br>
            <c:if test="${fn:containsIgnoreCase(store,'guoMei')}">ok ok</c:if><br>
            <c:if test="${fn:endsWith(store,'99')}">end</c:if><br>
            <c:out value="${fn:escapeXml('<>')}"/><br>
            <c:out value="${fn:indexOf(store,'om')}"/><br>
            <c:out value="${fn:join(array,'|')}"/><br>
            <c:out value="${fn:length(array)}"/><br>

    </body>
        <body>       
            <%
                String a[] = {"aa","bb","cc","dd"};
                request.setAttribute("array",a);
                request.setAttribute("store","guomei8899");
                request.setAttribute("user","u1,u2,u3,u4,u5");
                request.setAttribute("test","aBcDeF   ");
            %> 
            <c:out value="${fn:replace(store,'8','9')}"/><br>
            <c:out value="${fn:split(user,',')}"/><br>
            <c:out value="${fn:startsWith(store,'g')}"/><br>
            <c:out value="${fn:substring(store,2,5)}"/><br>
            <c:out value="${fn:substringAfter(store,'mei')}"/><br>
            <c:out value="${fn:substringBefore(store,'mei')}"/><br>
            <c:out value="${fn:toLowerCase(test)}"/><br>
            <c:out value="${fn:toUpperCase(test)}"/><br>
            <c:out value="${test}hoho"/><br>
            <c:out value="${fn:trim(test)}hoho"/><br>
        </body>
  • 相关阅读:
    MSRA-TD5000数据集使用详解
    2017CS231n学习笔记——计算机视觉的概述
    函数式非凡的抽象能力
    或许是领域建模的真相
    SpringBoot+ActiveMq实现订阅模式(Topic)消息队列
    SpringBoot下Activemq自定义MessageConverter
    spring boot 2.0类找不到EmbeddedServletContainerInitializedEvent
    Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration
    Intellij IDEA使用 lambda表达式报错-source1.5中不支持lambda表达式
    SpringBoot--实战开发--commons-lang3(三十五)
  • 原文地址:https://www.cnblogs.com/estellez/p/3956418.html
Copyright © 2020-2023  润新知