数据库中取出一大段文字!其中包括格式空格符!
上面代码可以实现空格和换行,其实就是把空格替换为html的 换行替换为<br/>
你查询数据库时一般返回的是一个Map或Table,你可以根据它判断,判断它是否为空,如果为空的话,在JSP页面得到你返回的Map或Table你会吧,Table table=request.getParameter("table")你这样写:<%
if(table.getRowCount>0){
for(int i=0i<table.getRowCount()i++){
%>
<tr>
<td<%= table.getCellValue(i,"这里是你表的字段",false)%></td>
</tr>
<%
}
}else{
%>没有对应的数据可以显示<%
}
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce"><tr align="center" height="25" bgcolor="d3eaef">
<td width="5%">
编号
</td>
<td width="10%">
标题
</td>
<td width="23%">
内容
</td>
<td width="10%">
发表日期
</td>
<td width="16%">
基本 *** 作
</td>
</tr>
<%
//获取新闻信息集合,newList是从后台返回来的集合变量
List nList = (List) session.getAttribute("newList")
NewsEntity new = null
if (nList.size() <= 0) {
%>
<tr height="22" bgcolor="#FFFFFF" align="center">
<td colspan="9" align="center">
暂无新闻信息
</td>
</tr>
<%
} else {
for (int i = 0i <nList.size()i++) {
new = (NewsEntity) mList.get(i)
%>
<tr height="22" bgcolor="#FFFFFF" align="center">
<td>
<%=new.getId() %>
</td>
<td>
<%=new.getTitle() %>
</td>
<td>
<%=new.getContent() %>
</td>
<td>
<%=new.time() %>
</td>
<td>
<a href="MusicServlet?forward=getNewsDetailById&ID=<%=new.getId()%>" >
<span class="STYLE2">编辑</span></a>|
<a href="MusicServlet?forward=doDelNewsById&ID=<%=new.getId()%>"
onclick="return confirm('您确定要删除该条信息吗?')"><span
class="STYLE2">删除</span></a>
</td>
</tr>
<%
}
}
%>
</table>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)