后台主页面新闻展示
完成后台主页面的新闻显示绑定 start
<!-- 需求:完成后台主页面的新闻显示绑定 start -->
<ul class="classlist">
<%
//加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//建立连接
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "123");
//sql语句
String sql = "select * from tb_news";
//将sql语句传入方法返回执行对象
PreparedStatement ps = conn.prepareStatement(sql);
//根据执行对象调用方法返回结果集对象
ResultSet rs = ps.executeQuery();
//遍历结果集
while (rs.next()) {
out.println("<li> <a href='admin_newsDetail.jsp?nid=" + rs.getInt(1) + "'>" + rs.getString(3)
+ "</a> <span> 作者:" + rs.getString(4)
+ "      <a href='admin_editNews.jsp?nid=" + rs.getInt(1)
+ "'>修改</a>      <a href='javascript:void(0)' onclick='clickdel(\""
+ rs.getInt(1) + "\")'>删除</a></span> </li>");
}
%>
<li class='space'></li>
<p align="right">
当前页数:[1/3] <a href="#">下一页</a> <a href="#">末页</a>
</p>
</ul>
显示后台主界面完整代码如下:
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新闻发布系统-后台主页</title>
<link rel="stylesheet" type="text/css" href="css/admin.css" />
</head>
<body>
<div id="header">
<div id="welcome">欢迎使用新闻管理系统!</div>
<div id="nav">
<div id="logo">
<img src="images/logo.jpg" alt="新闻中国" />
</div>
<div id="a_b01">
<img src="images/a_b01.gif" alt="" />
</div>
</div>
</div>
<div id="admin_bar">
<div id="status">
管理员:<%=request.getParameter("username")%>
登录      <a href="#">login out</a>
</div>
<div id="channel"></div>
</div>
<div id="main">
<div id="opt_list">
<ul>
<li><a href="admin.html">管 理 首 页</a></li>
<li><a href="add_news.jsp">新 闻 发 布</a></li>
<li><a href="admin_themeMaintain.html">主 题 维 护</a></li>
<li><a href="admin_themeMaintain.html">评 论 管 理</a></li>
<li><a style="color: red;" href="#">系统账号管理</a></li>
<li><a style="color: red;" href="#">注册用户管理</a></li>
</ul>
</div>
<div id="opt_area">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script language