[code]while(rs.next())
{
i++ ;
// 进行循环打印,打印出所有的内容,以表格形式
// 从数据库中取出内容
int id = rs.getInt(1) ;
String title = rs.getString(2) ;
String author = rs.getString(3) ;
String content = rs.getString(4) ;
if(keyword!=null)
{
// 需要将数据返红
title = title.replaceAll(keyword,"<font color=\"red\">"+keyword+"</font>") ;
author = author.replaceAll(keyword,"<font color=\"red\">"+keyword+"</font>") ;
content = content.replaceAll(keyword,"<font color=\"red\">"+keyword+"</font>") ;
}
%>
<tr>
<td><%=id%></td>
<td><a href="update.jsp?id=<%=id%>"><%=title%></a></td>
<td><%=author%></td>
<td><%=content%></td>
<td><a href="delete_do.jsp?id=<%=id%>">删除</a></td>
</tr>
<%
}[/code]
================================
只要在显示的时候做出处理即可
{
i++ ;
// 进行循环打印,打印出所有的内容,以表格形式
// 从数据库中取出内容
int id = rs.getInt(1) ;
String title = rs.getString(2) ;
String author = rs.getString(3) ;
String content = rs.getString(4) ;
if(keyword!=null)
{
// 需要将数据返红
title = title.replaceAll(keyword,"<font color=\"red\">"+keyword+"</font>") ;
author = author.replaceAll(keyword,"<font color=\"red\">"+keyword+"</font>") ;
content = content.replaceAll(keyword,"<font color=\"red\">"+keyword+"</font>") ;
}
%>
<tr>
<td><%=id%></td>
<td><a href="update.jsp?id=<%=id%>"><%=title%></a></td>
<td><%=author%></td>
<td><%=content%></td>
<td><a href="delete_do.jsp?id=<%=id%>">删除</a></td>
</tr>
<%
}[/code]
================================
只要在显示的时候做出处理即可