网吧网站留言本。主要使用基于MVC模式的JSP+JAVABEAN+SERVLET
源代码在线查看: searchok.jsp~34~
request.setCharacterEncoding("GBK");
%>
//添加分页
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(tt.trim().equals("0")){
response.sendRedirect("reSearch.jsp");
}
}
//计算取得总页数
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;
}
%>
pageSize) {%>
alert("超过当前最多页数!");
currentPage = 1;
startRecord = 0;
stopRecord = recordRows;
}
%>
alert("您要查找的页数不能低于1!!!");
currentPage = 1;
startRecord = 0;
stopRecord = recordRows;
}
%>
中青网络会所>>留言本
.style14 {color: #666666}
.style16 {
color: #0099FF;
font-weight: bold;
}
-->
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
function check(){
gopage=this.go.goPage.value;
if(gopage==""){
alert("请输入您要跳转到的页面。");
this.go.goPage.focus();
return false;
}else{
return true;
}
}
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,""+keyword+"");
}
if(classNames.equals("gbPerson")){
person=person.replaceAll(keyword,""+keyword+"");
}
if(classNames.equals("gbContent")){
content=content.replaceAll(keyword,""+keyword+"");
}
if(classNames.equals("gbReply")){
reply=reply.replaceAll(keyword,""+keyword+"");
}
}
//System.out.println(!reply.equals("暂无回复") + "\n\n\n\n\n");
%>
if(!face.equals("images/admin.gif")){
%>
%>
回复
|
删除
[
]
中青回复:
回复日期:【
】
总计
条
共有
/
页
每页
条
首页
上一页
下一页
尾页