引入头文件支持
<%@ 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>
<c:choose>
<c:when test="${fn:length(qesContent) > 20}">
<c:out value="${fn:substring(qesContent, 0, 20)}......${questionNewestList.username }" />
</c:when>
<c:otherwise>
<c:out value="${qesContents}" />
</c:otherwise>
</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 首尾的空格,并将其返回

JSTL截取字符串的更多相关文章

  1. 用jstl截取字符串

    用jstl截取字符串 2011-08-01 08:55 5485人阅读 评论(0) 收藏 举报 stringfunctionjavahtmljspencoding jstl以前在jsp页面截取字符串时 ...

  2. 使用jstl 截取字符串

    时常碰见这样的 问题:获取数据库中的文本域的时候经常是在p标签中的,在页面显示的时候也是带着p标签,如何去除p标签呢 这里提供一个使用jstl的方式 1.首先导入jstl的函数标签库 <%@ t ...

  3. JSTL截取字符串以及格式化时间

    fn函数里面有很多好用的方法 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions& ...

  4. 只显示 前100个字 java 实现截取字符串!使用! <c:if test="${fn:length(onebeans.info)>100 }">${ fn:substri

    博客 文章 只显示 前100个字 java 实现截取字符串!使用! <c:if test="${fn:length(onebeans.info)>100 }">$ ...

  5. EL表达式中如何截取字符串

    EL表达式中如何截取字符串 可以截取,用fn函数:<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/ ...

  6. jstl 处理字符串函数 substring spli等

    在jstl中的fn标签也是我们在网页设计中经常要用到的很关键的标签,在使用的时候要先加上头 <%@ taglib uri="http://java.sun.com/jsp/jstl/f ...

  7. ThinkPHP 模板substr的截取字符串函数

    ThinkPHP 模板substr的截取字符串函数在Common/function.php加上以下代码 /** ** 截取中文字符串 **/ function msubstr($str, $start ...

  8. shell编程常用的截取字符串操作

    1.          常用的字符串操作 1.1.           替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...

  9. [No0000A4]DOS命令(cmd)批处理:替换字符串、截取字符串、扩充字符串、获取字符串长度

    1.替换字符串,即将某一字符串中的特定字符或字符串替换为给定的字符串.举例说明其功能:========================================= @echo off set a ...

随机推荐

  1. 【Winform】Winform 制作一键发布web

    前言 最近web网站有个需要,就是打包给客户,客户能够自己手动的进行傻瓜式的安装发布web.找了很多资料,其中涉及到 文件解压 IIS操作 数据库还原 等. 发现现在就主要是两种解决方案: ①:使用V ...

  2. Codeforces Round #331 (Div. 2) B. Wilbur and Array 水题

    B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  3. nginx配置图片服务器

    这几天研究了一下nginx配置图片服务器的相关内容,个人的一些收获与大家分享一下: Nginx是目前非常流行的web服务器,它起源于俄罗斯.它具有处理速度快,并发量大,占用资源极低等优点,尤其对于静态 ...

  4. ssh连接阿里云一段时间不操作自动断开

    打开/etc/ssh/sshd_config 添加或修改: ClientAliveInterval 120 ClientAliveCountMax 0

  5. document.body.clientHeight与document.documentElement.clientHeight

    当你的网页有: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  6. Server Tomcat v7.0 Server at localhost failed to start.错误可能原因之一

    故事由来: 学Servlet中,突然发现启动Tomcat时出现这个问题 故事梗概: 学习servlet尽然能碰到服务器起不来的,百思不得其解,然后我百度,我FQgoogle,找stackoverflo ...

  7. CSS skills: 6) auto hide the top bar javascript

    //jquery $(document).ready(function(){ $(window).scroll(function() { $(this).scrollTop() > 10 ? $ ...

  8. 无需WEB服务器的WEBServices

    本文将介绍如何将Indy控件组与Delphi 6的Web Services (SOAP)支持相结合.关于如何创建Web Services的更多信息,请参阅Nick Hodges的文章,<Web上 ...

  9. css实现居中

    --在html常常用到居中 --1.可以用<center></center> --2.可以用css 演示代码: <!DOCTYPE html PUBLIC "- ...

  10. mysql 修改 character_set_database 编码格式

    操作系统:win10  x64 Server version : 5.5.46 MySQL Community Server (GPL) mysql 修改 character_set_database ...