jsp,div 限制字数,超出部分用省略号代替

1.我是用struts2标签做的:如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>博客列表</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/main.css">
	<script type="text/javascript">
		function goTo(maxPage){
			var currentPage = document.getElementById("text1").value;
			if(currentPage>maxPage || currentPage<1){
				alert("对不起,无法到达该页");
			}else{
				document.location.href="<%=request.getContextPath()%>/BlogAction_findAllBlog.action?pageNo="+currentPage;
			}
		}
	</script>
</head>
<body>
<div class="center_division">
	<div class="center_body">
		<table id="tb">
		<%--
		<tr>
			<td width="15%" bgcolor="#eef0f7">标题</td>
			<td bgcolor="#eef0f7">内容</td>
		</tr>
		--%>
		<s:iterator value="articleList" var="article">
		<tr>
			<td align="left" style="padding-left: 20px; font-size: 14px;">
				<a href="#"><s:property value="#request['articleTitle']"/></a>
			</td>
		</tr>
		<tr>
			<td>
			<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>
			</td>
		</tr>
		<tr>
			<td align="right" style="padding-right: 10px;">
			发布时间:<s:property value="#request['articleCreateDate']"/>
			<!-- 
			更新时间:<s:property value="#request['articleUpdateDate']"/>
			 -->
			</td>
		</tr>
		</s:iterator>
	</table>
	</div>
</div>
</body>
</html>


2.最后的效果截图如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值