如何在限制页面中显示的内容的字数?

来源:互联网 发布:淘宝话费充值代理 编辑:程序博客网 时间:2024/04/20 12:41

限制字数在100个以内:

1.使用jstl标签

 <c:if test="${c.content.length()>100}">

               ${c.content.substring(0,100)}...
            </c:if>
            <c:if test="${c.content.length()<=100}">
               ${c.content}...

            </c:if>

2.使用struts标签类库

<s:if test="#request['articleContent'].length()>100">  
                <s:property value="#request['articleContent'].substring(0,100)"/>......  
            </s:if>  
            <s:else>  
                <s:property value="#request['articleContent']"/>......  
            </s:else> 

0 0
原创粉丝点击