📄 adminnews.jsp
字号:
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/ch8.jsp" %>
<%
Driver DriverRecordset1 = (Driver)Class.forName(MM_ch8_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_ch8_STRING,MM_ch8_USERNAME,MM_ch8_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM News ORDER BY newsdate DESC");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%>
<%
Driver DriverRecordset2 = (Driver)Class.forName(MM_ch8_DRIVER).newInstance();
Connection ConnRecordset2 = DriverManager.getConnection(MM_ch8_STRING,MM_ch8_USERNAME,MM_ch8_PASSWORD);
PreparedStatement StatementRecordset2 = ConnRecordset2.prepareStatement("SELECT * FROM Manager");
ResultSet Recordset2 = StatementRecordset2.executeQuery();
boolean Recordset2_isEmpty = !Recordset2.next();
boolean Recordset2_hasData = !Recordset2_isEmpty;
Object Recordset2_data;
int Recordset2_numRows = 0;
%>
<%
int Repeat1__numRows = -1;
int Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
int Recordset1_first = 1;
int Recordset1_last = 1;
int Recordset1_total = -1;
if (Recordset1_isEmpty) {
Recordset1_total = Recordset1_first = Recordset1_last = 0;
}
//set the number of rows displayed on this page
if (Recordset1_numRows == 0) {
Recordset1_numRows = 1;
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them
if (Recordset1_total == -1) {
// count the total records by iterating through the recordset
for (Recordset1_total = 1; Recordset1.next(); Recordset1_total++);
// reset the cursor to the beginning
Recordset1.close();
Recordset1 = StatementRecordset1.executeQuery();
Recordset1_hasData = Recordset1.next();
// set the number of rows displayed on this page
if (Recordset1_numRows < 0 || Recordset1_numRows > Recordset1_total) {
Recordset1_numRows = Recordset1_total;
}
// set the first and last displayed record
Recordset1_first = Math.min(Recordset1_first, Recordset1_total);
Recordset1_last = Math.min(Recordset1_first + Recordset1_numRows - 1, Recordset1_total);
}
%>
<% String MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
String MM_keepBoth,MM_keepURL="",MM_keepForm="",MM_keepNone="";
String[] MM_removeList = { "index", MM_paramName };
// create the MM_keepURL string
if (request.getQueryString() != null) {
MM_keepURL = '&' + request.getQueryString();
for (int i=0; i < MM_removeList.length && MM_removeList[i].length() != 0; i++) {
int start = MM_keepURL.indexOf(MM_removeList[i]) - 1;
if (start >= 0 && MM_keepURL.charAt(start) == '&' &&
MM_keepURL.charAt(start + MM_removeList[i].length() + 1) == '=') {
int stop = MM_keepURL.indexOf('&', start + 1);
if (stop == -1) stop = MM_keepURL.length();
MM_keepURL = MM_keepURL.substring(0,start) + MM_keepURL.substring(stop);
}
}
}
// add the Form variables to the MM_keepForm string
if (request.getParameterNames().hasMoreElements()) {
java.util.Enumeration items = request.getParameterNames();
while (items.hasMoreElements()) {
String nextItem = (String)items.nextElement();
boolean found = false;
for (int i=0; !found && i < MM_removeList.length; i++) {
if (MM_removeList[i].equals(nextItem)) found = true;
}
if (!found && MM_keepURL.indexOf('&' + nextItem + '=') == -1) {
MM_keepForm = MM_keepForm + '&' + nextItem + '=' + java.net.URLEncoder.encode(request.getParameter(nextItem));
}
}
}
String tempStr = "";
for (int i=0; i < MM_keepURL.length(); i++) {
if (MM_keepURL.charAt(i) == '<') tempStr = tempStr + "<";
else if (MM_keepURL.charAt(i) == '>') tempStr = tempStr + ">";
else if (MM_keepURL.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + MM_keepURL.charAt(i);
}
MM_keepURL = tempStr;
tempStr = "";
for (int i=0; i < MM_keepForm.length(); i++) {
if (MM_keepForm.charAt(i) == '<') tempStr = tempStr + "<";
else if (MM_keepForm.charAt(i) == '>') tempStr = tempStr + ">";
else if (MM_keepForm.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + MM_keepForm.charAt(i);
}
MM_keepForm = tempStr;
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length() > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length() > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length() > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>消息发布管理接口</title>
<style type="text/css">
<!--
.style4 {color: #FFFFFF}
.STYLE5 {color: #FF0000}
-->
</style>
</head>
<body>
<p align="center"><img src="images/title.jpg" width="640" height="120" /></p>
<p align="right"><span style="position:absolute; width:104px; height:38px; z-index:6; left: 12px; top: 97px; background-image: url(images/news.jpg); layer-background-image: url(images/news.jpg); border: 1px none #000000;"><img src="images/adminnews.jpg" alt="news" width="318" height="39" /></span><a href="addnews.jsp?name=<%=(((Recordset2_data = Recordset2.getObject("loginname"))==null || Recordset2.wasNull())?"":Recordset2_data)%>">[新增消息发布]</a></p>
<p align="right" class="STYLE5">显示消息<%=(Recordset1_first)%>到<%=(Recordset1_last)%>,共<%=(Recordset1_total)%>条</p>
<table width="743" border="0">
<tr bgcolor="#669933">
<td width="151"><span class="style4">发布日期</span></td>
<td width="381"><span class="style4">发布主题</span></td>
<td width="197"><span class="style4">发布编辑</span></td>
</tr>
<% while ((Recordset1_hasData)&&(Repeat1__numRows-- != 0)) { %>
<% Object aaa = Recordset1.getObject("ID"); %>
<tr bgcolor="#CCFF66">
<td><%=(((Recordset1_data = Recordset1.getObject("newsdate"))==null || Recordset1.wasNull())?"":Recordset1_data)%></td>
<td><%=(((Recordset1_data = Recordset1.getObject("newstitle"))==null || Recordset1.wasNull())?"":Recordset1_data)%></td>
<td><A HREF="updatenews.jsp?<%= MM_keepNone + ((MM_keepNone!="")?"&":"") + "ID=" + aaa %>">[修改]</A> <A HREF="delnews.jsp?<%= MM_keepNone + ((MM_keepNone!="")?"&":"") + "ID=" + aaa %>">[删除]</A> </td>
</tr>
<%
Repeat1__index++;
Recordset1_hasData = Recordset1.next();
}
%>
</table>
<p align="left"> </p>
</body>
</html>
<%
Recordset1.close();
StatementRecordset1.close();
ConnRecordset1.close();
%>
<%
Recordset2.close();
StatementRecordset2.close();
ConnRecordset2.close();
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -