📄 searchok_jsp.java
字号:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
public final class searchok_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.Vector _jspx_dependants;
public java.util.List getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=GBK");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "top.htm", out, true);
out.write("\r\n");
out.write("\r\n");
request.setCharacterEncoding("GBK");
out.write('\r');
out.write('\n');
out.write(' ');
com.netbar.dao.gbDao gbdao = null;
synchronized (_jspx_page_context) {
gbdao = (com.netbar.dao.gbDao) _jspx_page_context.getAttribute("gbdao", PageContext.PAGE_SCOPE);
if (gbdao == null){
gbdao = new com.netbar.dao.gbDao();
_jspx_page_context.setAttribute("gbdao", gbdao, PageContext.PAGE_SCOPE);
}
}
out.write("\r\n");
out.write("\r\n");
//添加分页
int currentPage = 1; //当前页,初始为1
int recordRows = 10; //每页记录行数
int pageSize = 0; //总页数
int totalRecords;//表中总的记录数
String keyword= request.getParameter("keyword");
String className=request.getParameter("classname");
if(session.getAttribute("keyword")==null||session.getAttribute("keyword").equals("")){
session.setAttribute("keyword",keyword);
session.setAttribute("className",className);
}
if(keyword==null || keyword.equals("")){
keyword=(String)session.getAttribute("keyword");
className=(String)session.getAttribute("className");
}
//获取表中所有记录数。。
if(session.getAttribute("totalRecords")!=null){
String totalRecordstemp=(String)session.getAttribute("totalRecords");
totalRecords=Integer.parseInt(totalRecordstemp);
}else{
totalRecords = com.netbar.dao.gbDao.getSearchRecord(keyword,className);
session.setAttribute("totalRecords",totalRecords+"");
//System.out.println("总记录数:"+totalRecords);
String tt=(String)session.getAttribute("totalRecords");
if(totalRecords==0){
response.sendRedirect("reSearch.jsp");
return;
}
}
//计算取得总页数
if (totalRecords % recordRows == 0) {
pageSize = totalRecords / recordRows;
}
else {
pageSize = (totalRecords / recordRows) + 1;
}
String tempPage = request.getParameter("currentPage");
if (tempPage != "" && tempPage != null) {
currentPage = Integer.parseInt(tempPage);
}
String goPage = request.getParameter("goPage");
if (goPage != null) {
if (!goPage.equals("")) {
currentPage = Integer.parseInt(goPage);
}
}
//确认各页的起始和结束留言记录
int startRecord = recordRows*(currentPage - 1);
int stopRecord = startRecord + recordRows;
if (currentPage == pageSize) {
stopRecord = totalRecords;
}
out.write("\r\n");
out.write("\r\n");
if (currentPage > pageSize) {
out.write("\r\n");
out.write("<script type=\"text/javascript\">\r\n");
out.write(" alert(\"超过当前最多页数!\");\r\n");
out.write(" </script>");
currentPage = 1;
startRecord = 0;
stopRecord = recordRows;
}
out.write('\r');
out.write('\n');
if (currentPage < 1) {
out.write("\r\n");
out.write("<script type=\"text/javascript\">\r\n");
out.write(" alert(\"您要查找的页数不能低于1!!!\");\r\n");
out.write(" </script>");
currentPage = 1;
startRecord = 0;
stopRecord = recordRows;
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<title>中青网络会所>>留言本</title>\r\n");
out.write("<meta name=\"Robots\" content=\"all\">\r\n");
out.write("<meta name=\"Generator\" content=\"Dreamweaver,ASP\">\r\n");
out.write("<meta name=\"copyright\" content=\"Copyright 中青网络会所 2007-2008\">\r\n");
out.write("<meta name=\"Author\" content=\"zqnet\">\r\n");
out.write("<meta name=\"description\" content=\"中青网络会所留言本\">\r\n");
out.write("<meta name=\"keywords\" content=\"留言本,中青\">\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<link href=\"css.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
out.write("\r\n");
out.write("<style type=\"text/css\">\r\n");
out.write(" <!--\r\n");
out.write(" .style14 {color: #666666}\r\n");
out.write(" .style16 {\r\n");
out.write(" color: #0099FF;\r\n");
out.write(" font-weight: bold;\r\n");
out.write(" }\r\n");
out.write(" -->\r\n");
out.write("</style>\r\n");
out.write("<script language=\"JavaScript\" type=\"text/JavaScript\">\r\n");
out.write("<!--\r\n");
out.write("function MM_reloadPage(init) { //reloads the window if Nav4 resized\r\n");
out.write(" if (init==true) with (navigator) {if ((appName==\"Netscape\")&&(parseInt(appVersion)==4)) {\r\n");
out.write(" document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}\r\n");
out.write(" else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();\r\n");
out.write("}\r\n");
out.write("MM_reloadPage(true);\r\n");
out.write("//-->\r\n");
out.write("</script><script type=\"text/javascript\" language=\"javascript\">\r\n");
out.write("function check(){\r\n");
out.write(" gopage=this.go.goPage.value;\r\n");
out.write(" if(gopage==\"\"){\r\n");
out.write(" alert(\"请输入您要跳转到的页面。\");\r\n");
out.write(" this.go.goPage.focus();\r\n");
out.write(" return false;\r\n");
out.write(" }else{\r\n");
out.write(" return true;\r\n");
out.write(" }\r\n");
out.write("}\r\n");
out.write("</script></head>\r\n");
out.write("<body background=\"images/bg_001.gif\" bgproperties=\"fixed\">\r\n");
out.write("<table width=\"680\" height=\"12\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"biao_bdr\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td>\r\n");
out.write(" <img src=\"images/bar_1.gif\" width=\"678\" height=\"20\">\r\n");
out.write(" </td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
Vector vcs=new Vector();
if(session.getAttribute("vcs")!=null){
vcs=(Vector)session.getAttribute("vcs");
}else{
vcs = gbdao.getSelectData(keyword,className);
}
session.setAttribute("vcs",vcs);
//String title,content,reply,person,web,mail,qq,face,ip,pcname,time,redate;
//int id;
for (int i = startRecord; i < stopRecord; i++) {
com.netbar.bean.gbBean gbbean = (com.netbar.bean.gbBean)vcs.get(i);
int id = gbbean.getGbID();
String title = gbbean.getGbTitle();
String content = gbbean.getGbContent();
String reply = gbbean.getGbReply();
String person = gbbean.getGbPerson();
String web = gbbean.getGbWeb();
String mail = gbbean.getGbMail();
String qq = gbbean.getGbQQ();
String face = gbbean.getGbFace();
String ip = gbbean.getGbIP();
String pcname = gbbean.getGbPcname();
String time = gbbean.getGbTime();
String redate = gbbean.getGbRedate();
//将查询的关键字返红显示
if(session.getAttribute("keyword")!=null){
String classNames=(String)session.getAttribute("className");
if(classNames.equals("gbTitle")){
title=title.replaceAll(keyword,"<font color='red'>"+keyword+"</font>");
}
if(classNames.equals("gbPerson")){
person=person.replaceAll(keyword,"<font color='red'>"+keyword+"</font>");
}
if(classNames.equals("gbContent")){
content=content.replaceAll(keyword,"<font color='red'>"+keyword+"</font>");
}
if(classNames.equals("gbReply")){
reply=reply.replaceAll(keyword,"<font color='red'>"+keyword+"</font>");
}
}
//System.out.println(!reply.equals("暂无回复") + "\n\n\n\n\n");
out.write("\r\n");
out.write("<table width=\"680\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#EBF2F8\" class=\"biao_bdr\" style=\"table-layout:fixed;word-break:break-all\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td width=\"140\" rowspan=\"2\" style=\"border-right: 1px solid #d1e0f0;\">\r\n");
out.write(" <table width=\"98%\" height=\"35\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td>\r\n");
out.write(" <div align=\"center\">\r\n");
out.write(" <font style=\"FONT-SIZE: 10pt; FILTER: shadow(color=#C0C0C0); COLOR: #000000; HEIGHT: 1px\">");
out.print(person);
out.write(" </font>\r\n");
out.write(" </div>\r\n");
out.write(" </td>\r\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -