📄 album.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,com.alumni.bean.*"%>
<%
//驱动数据库
Connection conn=null;
Statement stmt=null;
ResultSet albumRs=null;
DBConnection dbConn=null;
ResultSetController rsc=null;
String currentPage=null;
int row=5;
int column=7;
String[][] data=null;
int totalCounts=0;
int currentPageNum=0;
int rowsPerPage=0;
int totalPages=0;
currentPage=request.getParameter("page");
if(currentPage==null||currentPage.equals(""))
{
currentPageNum=1;
}
else
{
currentPageNum=Integer.parseInt(currentPage);
}
//是否已经登陆
boolean hasLogin=false;
//获取SESSION中的用户信息
String loginUserClass=(String)session.getAttribute("adminClass");
if(loginUserClass==null)
{
loginUserClass="0";
}
Boolean bo=(Boolean)session.getAttribute("hasLogin");
if(bo==null||bo.booleanValue()==false)
{
hasLogin=false;
data=new String[5][7];
response.sendRedirect("login.jsp");
}
else
{
hasLogin=true;
//连接到数据库
dbConn=new DBConnection();
rsc=new ResultSetController();
conn=dbConn.getConnectionToAccess(application.getRealPath("/db/alumni.mdb"));
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="SELECT A.ID,A.PIC_NAME,A.UPLOAD_DATE,A.PIC_NOTE,U.ID,U.USERNAME,U.REALNAME FROM ALBUM AS A LEFT OUTER JOIN USERINFO AS U ON A.USER_ID=U.ID ORDER BY A.UPLOAD_DATE DESC";
rsc.setConnectionObject(conn);
rsc.setQueryString(sql);
rsc.setCurrentPageNum(currentPageNum);
rsc.setRowsPerPage(row);
rsc.run();
//获得页面数据
totalCounts=rsc.getTotalCounts();
currentPageNum=rsc.getCurrentPageNum();
rowsPerPage=rsc.getRowsPerPage();
totalPages=rsc.getTotalPages();
//当记录总数小于每页可显示数,则取每页可显示数作为数组的行
//否则取最小的记录作为数组的行
if(totalCounts>rowsPerPage)
{
row=rowsPerPage;
}
else
{
row=totalCounts;
}
data=new String[row][column];
int i=0;
while(rsc.isAvailable())
{
for(int j=0;j<column;j++)
{
data[i][j]=rsc.getData(j+1);
}
i++;
}
}
if(dbConn!=null)
{
dbConn.close();
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>班级相册</title>
<link href="css/index.css" rel="stylesheet" type="text/css">
</head>
<body>
<jsp:include page="include/top.htm"/>
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td><a href="#uploadPic"><img src="image/index/uploadpic.gif" width="90" height="25" border="0"></a></td>
</tr>
</table>
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="300">共有<font color="#FF0000"><strong><%=totalCounts%></strong></font>条记录,每页显示<font color="#FF0000"><strong><%=rowsPerPage%></strong></font>条,当前页<font color="#FF0000"><strong><%=currentPageNum%></strong></font>/<font color="#FF0000"><strong><%=totalPages%></strong></font></td>
<td>
<%
for(int i=0;i<totalPages;i++)
{
out.print("<a href='album.jsp?page="+(i+1)+"'>");
out.print("["+(i+1)+"]");
out.print("</a>");
}
%>
</td>
</tr>
</table>
<%
if(loginUserClass!=null&&Integer.parseInt(loginUserClass)>0)
{
out.println("<form method='post' name='adminForm' target='_self' id='adminForm' action='/servlet/AlbumAdminServlet'>");
}
%>
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#99cc66">班级相册</td>
</tr>
<%
for(int m=0;m<row;m++){
%>
<tr><td bgcolor="#e7e7e7">上传者:<%=data[m][5]%> 上传日期:<%=data[m][2]%> 说明:<%=data[m][3]%>
<%
if(loginUserClass!=null&&Integer.parseInt(loginUserClass)>0)
{
out.print("删除");
out.println("<input name='id' type='checkbox' value='"+data[m][0]+"'>");
}
%>
</td>
</tr>
<tr><td valign="top" bgcolor="#FFFFFF"><img src="upload/album/<%=data[m][1]%>"><br>
<br><br></td></tr>
<%}%>
</table>
<table width="95%" border="0" align="center"><tr><td align="right">
<%
if(loginUserClass!=null&&Integer.parseInt(loginUserClass)>0)
{
out.println("<table width='95%' border='0' align='center'><tr><td align='right'><input name='doAdmin' type='submit' id='doAdmin' value='提交操作'></td></tr></table>");
out.println("</form>");
}
%>
</td></tr></table><%
if(loginUserClass!=null&&Integer.parseInt(loginUserClass)>0)
{
out.println("</form>");
}
%>
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="300">共有<font color="#FF0000"><strong><%=totalCounts%></strong></font>条记录,每页显示<font color="#FF0000"><strong><%=rowsPerPage%></strong></font>条,当前页<font color="#FF0000"><strong><%=currentPageNum%></strong></font>/<font color="#FF0000"><strong><%=totalPages%></strong></font></td>
<td>
<%
for(int i=0;i<totalPages;i++)
{
out.print("<a href='album.jsp?page="+(i+1)+"'>");
out.print("["+(i+1)+"]");
out.print("</a>");
}
%>
</td>
</tr>
</table>
<form action="/servlet/UploadAlbumServlet" method="post" enctype="multipart/form-data" name="uploadForm" target="_self" id="uploadForm">
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#000000">
<tr>
<td colspan="2" bgcolor="#99CC66">上传相片<a name="#uploadPic"></a></td>
</tr>
<tr>
<td width="200" bgcolor="#E7E7E7">选择相片<br>
文件大小限制在1M以下</td>
<td bgcolor="#E7E7E7"><input name="uploadPic" type="file" class="form" id="uploadPic" size="50"></td>
</tr>
<tr>
<td bgcolor="#E7E7E7">简要说明<br>
请控制在50字以内</td>
<td bgcolor="#E7E7E7"><input name="picNote" type="text" class="form" id="picNote" size="50" maxlength="100"></td>
</tr>
<tr align="center" bgcolor="#FFFFFF">
<td colspan="2"><input name="Submit" type="submit" class="form" value="上传相片"></td>
</tr>
</table>
</form>
<jsp:include page="include/bottom.htm"/>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -