使用fn函数控制页面显示内容

在使用EL的时候,不可避免的遇到,截取字符串,判断字符串长度等情况。这里给出简单的通过fn函数操作字符串的deamon。

1、页面引入标签

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

 2、对内容的处理

<c:choose><c:when test='${fn:length(dutyLog.content) >= 100}'>${fn:substring(dutyLog.content,0,100)}...</c:when><c:otherwise>${dutyLog.content}</c:otherwise></c:choose>
 ${fn:length(dutyLog.content)}获取dutyLog.content的对应长度;
${fn:substring(dutyLog.content,0,100)}截取dutyLog.content的长度,${fn:substring(str,beg,end)}

特此记录,以待下次使用。

人生苦短,我用python
原文地址:https://www.cnblogs.com/pigga/p/10098275.html