⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board.jsp

📁 jsp论坛开发系统
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<%@ include file="check.jsp"%>
<%@ include file="top.jsp"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<jsp:useBean id="sp" class="spage.ShowPage" scope="session"/>
<html>
<head>
<title>分类讨论区</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<script language="javaScript">
function detailwin(id)
{
	window.open('detailuser.jsp?detailid='+id,'infoWin','height=200,width=700,scrollbars=yes,resizable=yes');
}
</script>
<body>
<%!
	String type="";
	String key="";
	String sql1="";
	String sql2="";
	String logrank=""; 
	String boardid="";
	ResultSet rs=null;
	ResultSet temp=null;
	//每页显示的记录个数
	int size = 10;
	//当前页号
	int p = 1;
	//全部的页数
	int totalPage = 1;
%>
<%
	request.setCharacterEncoding("gb2312");
	if(request.getParameter("stype")!=null)
		type=request.getParameter("stype");
	if(request.getParameter("skey")!=null)
		key=request.getParameter("skey");
	if(request.getParameter("boardid")!=null)
	{
		boardid=request.getParameter("boardid");
		session.setAttribute("boardid",boardid);
	}
	if(session.getAttribute("boardid")!=null)
		boardid=(String)session.getAttribute("boardid");
	logrank=(String)session.getAttribute("rank");
	String board="";
	if(boardid.equals("1"))
		board="技术交流";
	else if(boardid.equals("2"))
		board="美食天地";
	else
		board="生活五味";
%>
<table width="100%" cellpadding="3" cellspacing="0" border bordercolor="#ff6600" bordercolorlight="#FFFFFF">
<tr>
<th background="images/bg1.gif" align="center" height="28"><font size="3"><b>欢迎您光临--<%=board%>--讨论区!</b></font></th>
</table>
<center>
<form action="board.jsp" method="post">
请选择查询类别:<select name="stype">
		<option value="title" <%if(type!=null) if(type.equals("title")) out.print("selected");%>>按主题名</option>
		<option value="name" <%if(type!=null) if(type.equals("name")) out.print("selected");%>>按作者名</option>
		<option value="content" <%if(type!=null) if(type.equals("content")) out.print("selected");%>>按内容</option>
		</select>
请输入查询关键字:<input type="text" name="skey" size="10" value="<%if(key!=null) out.println(key);%>">
<input type="submit" value="确定">
</form>
<%@ include file="toparticle.jsp"%>
<table width="95%" cellpadding="3" cellspacing="0" border bordercolor="#ff6600" bordercolorlight="#FFFFFF">
<tr align="center">
<th background="images/bg1.gif">状态</th><th background="images/bg1.gif">主题</th><th background="images/bg1.gif">作者</th><th background="images/bg1.gif">回复</th><th background="images/bg1.gif">最后更新</th>
<%
	if(logrank.equals("4")||logrank.equals(boardid))
	{
%>
<th background="images/bg1.gif">加精</th>
<%
	}
	sql1="select * from article INNER JOIN [user] ON article.authorID = user.userid where reID=0 and boardID="+boardid;
	sql2="select count(*) from article INNER JOIN [user] ON article.authorID = user.userid where reID=0 and boardID="+boardid;
	if(type!=null && key!=null && !type.equals("") && !key.equals(""))
	{
		if(type.equals("name"))
		{
			sql1 += " and "+type+" ='"+key+"'";
			sql2 += " and "+type+" ='"+key+"'";	
		}
		else
		{
			sql1 += " and "+type+" like '%"+key+"%'";
			sql2 += " and "+type+" like '%"+key+"%'";	
		}
	}
	sql1+=" order by pubtime desc";		
	temp=conn.executeQuery(sql2);
	int totalrecord=0;
	if(temp.next())
		totalrecord = temp.getInt(1);
	// 如果是当前页码的整数倍	
	if(totalrecord % size ==0) totalPage = totalrecord / size;  
	// 如果最后还空余一页
	else  totalPage =  totalrecord / size + 1; 
	if(totalPage == 0) totalPage = 1;
	temp.close();
	try {
		if(request.getParameter("p")==null || request.getParameter("p").equals("")) 
		{
		   if(session.getAttribute("boardp")==null)
			p = 1;
		   else
			p = ((Integer)session.getAttribute("boardp")).intValue();
		}
		else
		{
		   p = Integer.parseInt(request.getParameter("p"));			   session.setAttribute("boardp",new Integer(p));
		}
	} 
	// 捕获用户从浏览器地址拦直接输入非数字信息而引起的异常
	catch(NumberFormatException e) {  
		   p = 1;
	}
	if(p < 1)  p = 1;
	if(p > totalPage) p = totalPage;
	rs=conn.executeQuery(sql1);
	if(rs.next())
	{
		if(logrank.equals("4")||logrank.equals(boardid))
			out.println(sp.artPrintPage(rs,p,size,true,true));
		else
			out.println(sp.artPrintPage(rs,p,size,false,true));
	}
%>
</table>
<form Action="board.jsp" Method="GET">
<%
  for(int i=1;i<=totalPage;i++) {
      out.println("<a href=board.jsp?p=" + i +">" + i + "</a>&nbsp;&nbsp;");
  }
%>
  <p>输入页数:<input type="text" name="p" size="3"> 
     页数:<font color="red"><%=p%>/<%=totalPage%></font> 
  </p>
</form>
</center>
<%
	rs.close();
	conn.close();
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -