JSP中实现全文检索
<td width="15%" height="20" align="center">
<%=myNews.getType()%>
&nbs; </td>
<td width="15%" height="20" align="center">
<%=myNews.getMan_add()%>
</td>
<td width="25%" height="20" align="center">
<%=myNews.getTime()%>
</td>
</tr>
<% } } else{ out.println("对不起,没有搜索到您要查找的新闻");} //和最前边的else对应,判断是否有记录 %>
<tr bgcolor="#B7D79F">
<td colspan="4" height="2"></td>
</tr>
<tr>
<td colspan=4>
<p align=right>
</td>
</tr>
</table>
<P align=center> 共搜索到新闻 <%=j%> 条
</body>
</html>
System.out.println(e.toString());
}
}
public class News { //存放结果的类
String content;
String release_time;
String type;
String man_add;
String title;
public String getContent() { return this.content; }
public String getTitle() { return this.title; }
public String getTime() { return this.release_time; }
public String getType() { return this.type; }
public String getMan_add() { return this.man_add; }
}
}
下面的代码是调用的:aftsearch.jsp
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.util.*" %>
<%
request.setCharacterEncoding("GB2312");
String keyword=request.getParameter("keyword"); //接收关键字
String trace=getServletContext().getRealPath("/")+"xwxx//news//";//主体新闻存放路径
NEWS.newsSearch newsSearch=new NEWS.newsSearch();//初始化检索的bean
newsSearch.setFilePath(trace);//设置主体新闻路径
newsSearch.setKeyWord(keyword);//设置关键字
newsSearch.search();//检索
Vector news=newsSearch.getResult();//取到结果
%>
<html>
<head>
<title>新闻搜索</title>
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link rel="stylesheet" href="../css/style3.css">
&l;script LANGUAGE="javascript">
function open_window(id)
{
locat="./news/"+id+".html";
更多电脑、家电软硬件维修资讯请访问维修技术











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面