📄 searchsult.jsp
字号:
<%@ page contentType="text/html; charset=GBK"%>
<%@ page language="java" import="java.util.*,popten.web.*" %>
<%@ page errorPage="error.jsp" %>
<% News secnews = new News();
String keyword,scope,cata,str;
str=(request.getParameter("action")!=null && request.getParameter("action").equals("coun"))?"coun":"dat";
if(request.getParameter("keyword")!=null && request.getParameter("scope")!=null && request.getParameter("cata")!=null){
session.putValue("keyword",request.getParameter("keyword"));
session.putValue("scope",request.getParameter("scope"));
session.putValue("cata",request.getParameter("cata"));
}
keyword=(String)session.getValue("keyword");
scope=(String)session.getValue("scope");
cata=(String)session.getValue("cata");
int newcata=Integer.parseInt(cata);
if(request.getParameter("search")!=null && request.getParameter("search").equals("1")){
Vector newsList = new Vector();
newsList = secnews.searchNews(keyword,scope,newcata,str);
session.setAttribute("newsList",newsList);
}
//分页开始
int pagenum;//显示的页数
int pagesize;//一页显示的行数
int pagecoun;//总页数
int rowcoun;//总的记录数
String strPage = request.getParameter("pagenum");
if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
pagenum = 0;
}
else{//将字符串转换成整型
pagenum = Integer.parseInt(strPage);
if(pagenum<1) pagenum = 0;
}
Vector newsListB=(Vector)session.getAttribute("newsList");
pagesize=20;
rowcoun=newsListB.size();
pagecoun=(rowcoun+pagesize-1) / pagesize;
int stopage=pagenum+20;//本页的最后一条记录
if(stopage>rowcoun)stopage=rowcoun;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>POPTEN</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>
<body>
<%@ include file="head.jsp"%>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bgcolor="#ffffff" width="760" >
<tbody>
<tr>
<td width="200" valign="top"><%@ include file="left.jsp"%></td>
<td width="560" valign="top">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="560" bgcolor="#f2f8ff" height="100%">
<%News listnews=news.loadNews(request);%>
<tr>
<td width="15" class="td4">
<img border="0" src="img/null.gif"></td>
<td width="525" class="td5">
<img border="0" src="img/null.gif">当前位置:<a href="index.jsp">网站首页</a> >> 搜索结果</td>
<td width="20" class="td6">
<img border="0" src="img/jiao3.gif"></td>
</tr>
<tr>
<td width="100%" colspan="3" class="td7" valign="top" align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="98%">
<tr>
<th width="36%">
<p align="center">标题</th>
<th width="32%"><p align="center"><a href="searchsult.jsp?pagenum=<%=pagenum%>&search=1">日期</a></th>
<th width="32%">
<p align="center"><a href="searchsult.jsp?action=coun&pagenum=<%=pagenum%>&search=1">浏览次数</a></th>
</tr>
<%for(int i=pagenum;i<stopage;i++){
News newsall= (News)newsListB.elementAt(i);
%>
<tr>
<td width="36%"><a href="news.jsp?news_id=<%=newsall.getnews_id()%>"><%=newsall.getnews_title()%></a></td>
<td width="32%"><p align="center"><font color=#808080><%=newsall.getdat()%></font></td>
<td width="32%"><p align="center"><font color=#808080>[<%=newsall.getcoun()%>]</font></td>
</tr>
<%}%>
<tr>
<td width="100%" colspan="3"><p align="right">共 <%=pagecoun%> 页
<%if(pagenum!=0){out.println("<a href='searchsult.jsp?pagenum="+(pagenum-20)+"'>上一页</a>");}
for(int j=0;j<pagecoun;j++){
if(j*20==pagenum){
out.println("["+(j+1)+"]");
}
else{
out.println("<a href='searchsult.jsp?pagenum="+j*20+"'>"+(j+1)+"</a>");
}
}
if(pagenum<20*(pagecoun-1)){out.println("<a href='searchsult.jsp?pagenum="+(pagenum+20)+"'>下一页</a> ");}
%></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15">
<img border="0" src="img/jao5.gif" width="15" height="15"></td>
<td width="525" class="td8">
<img border="0" src="img/null.gif" width="2" height="2"></td>
<td width="20" class="td9">
<img border="0" src="img/null.gif" width="2" height="2"></td>
</tr>
</table></td>
</tr>
</tbody>
</table>
<%@ include file="foot.htm"%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -