`
月亮不懂夜的黑
  • 浏览: 151676 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用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)}

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

 

0
1
分享到:
评论
2 楼 月亮不懂夜的黑 2013-03-22  
freezingsky 写道
各种亮! 

why?
1 楼 freezingsky 2013-03-22  
各种亮! 

相关推荐

Global site tag (gtag.js) - Google Analytics