zoukankan      html  css  js  c++  java
  • JSTL截取字符串

    引入头文件支持
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

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

    1
    <c:set var="qesContent" value="${questionNewestList.qesContent}"></c:set> 2 <c:choose> 3 <c:when test="${fn:length(qesContent) > 20}"> 4 <c:out value="${fn:substring(qesContent, 0, 20)}......${questionNewestList.username }" /> 5 </c:when> 6 <c:otherwise> 7 <c:out value="${qesContents}" /> 8 </c:otherwise> 9 </c:choose>

     fn字符串一些常用的函数

    函数

     描述

     fn:contains(string, substring)

     如果参数string中包含参数substring,返回true

     fn:containsIgnoreCase(string, substring)

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

     fn:endsWith(string, suffix)

     如果参数 string 以参数suffix结尾,返回true

     fn:escapeXml(string)

     将有特殊意义的XML (和HTML)转换为对应的XML character entity code,并返回

     fn:indexOf(string, substring)

     返回参数substring在参数string中第一次出现的位置

     fn:join(array, separator)

     将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。

     fn:length(item)

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

     fn:replace(string, before, after)

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

     fn:split(string, separator)

     返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素

     fn:startsWith(string, prefix)

     如果参数string以参数prefix

    开头,返回true

     fn:substring(string, begin, end)

     返回参数string部分字符串, 从参数begin开始到参数end位置,包括end位置的字符

     fn:substringAfter(string, substring)

     返回参数substring在参数string中后面的那一部分字符串

     fn:substringBefore(string, substring)

     返回参数substring在参数string中前面的那一部分字符串

     fn:toLowerCase(string)

     将参数string所有的字符变为小写,并将其返回

     fn:toUpperCase(string)

     将参数string所有的字符变为大写,并将其返回

     fn:trim(string)

     去除参数string 首尾的空格,并将其返回

  • 相关阅读:
    Flex Box 简单弹性布局
    CSS 0.5px 细线边框的原理和实现方式
    前端模块化方案全解(CommonJS/AMD/CMD/ES6)
    用信鸽来讲解HTTPS的知识
    __name__ == "__main__"的作用是什么?
    如何自学计算机科学与技术(Teach Yourself Computer Science)
    中文技术文档的写作规范
    'adb remount'的作用是什么?在什么情况下有用?
    使用python遍历文件夹取出特定的字符串
    Python&Appium实现安卓手机图形解锁
  • 原文地址:https://www.cnblogs.com/bb1119/p/5385883.html
Copyright © 2011-2022 走看看