日期:2014-05-20 浏览次数:20867 次
<c:set var="str" value="abcdefghijklmnopqrstuvwxyz" /> 
<c:choose> 
<c:when test="${fn:length(str) > 10}"> 
<c:out value="${fn:substring(str, 0, 10)}......" /> 
</c:when> 
<c:otherwise> 
<c:out value="${str}" /> 
</c:otherwise> 
</c:choose>
------解决方案--------------------
EL没有自动判断功能,必须你自己判断进行处理。
------解决方案--------------------
<style type="text/css">
.ellipsis a{display: block;width: 300px;overflow: hidden;white-space: nowrap;-o-text-overflow: ellipsis;text-overflow:ellipsis;}   
/* firefox only */  
.ellipsis:not(p) {clear: both;}   
.ellipsis:not(p) a {max-width: 300px;float: left;}   
.ellipsis:not(p):after {content: "...";float: left;width: 25px;padding-left: 1px;}  
</style>
  <body>
    <div class="ellipsis"><a href="">如果文字太长将会被截取后面字符使用省略号代替</a></div>
  </body>