2023年java第一次随堂测试(不完善!!!)
一些感想和说在前面的话:首先我这个一堆烂代码是不完善的,而且目前我也无法独立解决我遇到的问题,为了能解决这些问题,我一定要再多学点javaweb的内容;
对于这次考试,我准备的不是很充分,可以说是临时抱佛脚;在考试前几天疯狂地敲代码,然后收获甚微,甚至出现了预料之外的问题,这就说明我的水平还是大大的不足;
这次的考试总体来说还是CRUD,以及用户角色权限等互相映射,还有密码设置,匿名回复,验证码问题等等;王建民老师说,如果我们能在3h内完整地写出这道题目,那么我们就可以当“猪”了,
可是我还不够当“猪”,更多的问题会继续反馈在博客园中。
课前测试试卷(180分钟)
河北省环保监测中心网络新闻发布系统(卷面成绩40分,占课程过程考核20分)
1、项目需求:
河北省环保监测中心网络新闻为搭建公众信息交流平台,决定建立新闻发布平台。新闻发布平台按内容包括中心新闻、企业环保信息发布等若干新闻栏目,新闻撰稿人可登陆平台发布新闻,每个新闻栏目至少有一位新闻栏目管理员,负责审查新闻撰稿人所发的新闻稿件,在审查通过后,对应新闻才可以显示在对应新闻栏目上,一般用户登录后才可以看到,另外还可以删除过时或无用的信息。另外,系统管理员可以对用户进行管理和对新闻栏目进行调整。新闻发布流程如下:
2.系统要求与功能设计
2.1 页面要求
(1)通过浏览器查看,能适应常用分辨率;(1分)
(2)布局合理、结构清晰、页面完整;(1分)
(3)网站页面整体风格统一;(1分)
(4)首页为用户登录页面,不同角色用户登录后,进入相应的功能页,要求密码在数据库中加密;(4分)
(5)新闻撰稿人功能页:在线撰写与修改稿件、查看已写稿件及修改意见;
(6)普通用户功能页:浏览相应栏目新闻、用户评论新闻(可匿名)、浏览其他用户评论;
(7)新闻栏目管理员功能页:浏览与管理本栏目待发与已发新闻;
(8)系统管理功能页:用户注册、用户权限管理、新闻栏目管理;
(9)对每页中的查询结果推荐采用分页显示。
2.2 功能要求
(1)在线撰写新闻稿件:新闻撰稿人在线撰写新闻,选择栏目,正式提交;(2分)
(2)查看修改意见:新闻撰稿人查看新闻栏目管理员提出的修改意见;(1分)
(3)修改新闻稿件:新闻撰稿人根据修改意见可以对新闻进行修改;(1分)
(4)查询已经撰写的新闻:新闻撰稿人可以查看自己已经撰写的新闻;(1分)
(5)浏览新闻:普通用户可以浏览栏目的新闻(按照时间倒排);(1分)
图1 新闻发布流程
(6)发表评论回复:普通用户可以对新闻进行发表评论,可选择匿名回复;(1分)
(7)按照一定条件查询新闻:栏目管理员可以按照时间段,新闻关键字等条件进行查询;(2分)
(8)管理待发与已发新闻:新闻栏目管理员可以批准新闻发布、删除不合适新闻、给出撰稿人修改意见、对已发的过时新闻进行删除;(2分)
(9)管理新闻评论回复:新闻栏目管理员可以查看、删除、禁止新闻的回复;(2分)
(10)管理新闻栏目:新开新闻栏目、删除新闻栏目、合并新闻栏目、更改新闻栏目的基本信息;(2分)
(11)用户管理:管理员可以查询用户、批准新用户、暂停用户、为用户赋予角色,普通用户可以修改用户资料。(2分)
2.1,2.2 评分标准:以上各项分值为页面要求和功能要求,各项分值合计(24分);除此以外设计出合理的数据库和数据表(3分),数据库连接正常(2分),设计出用户权限管理(6分)。
2.3 网站发布
(1)网站制作完成后需指定一台机器作为服务器发布。
(2)在其他主机上可正常浏览。
评分标准:能够在Tomcat服务器中正确部署(3分),其它主机可正常浏览(2分);
2.4 注意事项
(1)网站首页(登录页) 统一使用index.*命名。(*表示源文件的后缀名)。
(2)请选手填写以下表格:
网站文件路径 |
|
|
网站数据库名称 |
|
|
角色名 |
登录名 |
密码 |
|
|
|
|
|
|
|
|
|
|
|
|
代码结构:
数据库部分:
代码实现部分:
UserDao.java:
package dao;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.sql.*;
import util.DBUtil;
import java.sql.*;
public class UserDao {
public static Connection getConnection() throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jm0207", "root", "123456");
return con;
}
//!!!!!!增加新闻
public void add(String a1, String a2, String a3,String a4,String a5)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into doc_list (title,keyy,owner,timee,col) values (?,?,?,?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a1);
preparedStatement.setString(2, a2);
preparedStatement.setString(3, a3);
preparedStatement.setString(4, a4);
preparedStatement.setString(5, a5);
preparedStatement.executeUpdate();
}
//!!!!!!修改新闻
public void update(String a1, String a2, String a3,String a4,String a5)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "update doc_list set keyy=?, owner=?, timee=?, col=? where title=?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a2);
preparedStatement.setString(2, a3);
preparedStatement.setString(3, a4);
preparedStatement.setString(4, a5);
preparedStatement.setString(5, a1);
preparedStatement.executeUpdate();
}
//!!!!!!删除新闻
public void delete(String a1) throws Exception{
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "delete from doc_list where title = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a1);
preparedStatement.executeUpdate();
}
//!!!!!!新闻评论
public void comm(String a1)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into doc_list (comm) values (?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a1);
preparedStatement.executeUpdate();
}
//!!!!!!新闻修改意见
public void com_update(String a1,String a2)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "update doc_list set com = ? where title=?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a2);
preparedStatement.setString(2, a1);
preparedStatement.executeUpdate();
}
//!!!!!!新闻评论删除
public void comm_delete(String a1)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "alter doc_list drop comm = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a1);
preparedStatement.executeUpdate();
}
public void update(String a1, String a2, String a3)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "update doc_list set title=?, owner=?, place=? where title=?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a1);
preparedStatement.setString(2, a2);
preparedStatement.setString(3, a3);
preparedStatement.setString(4, a1);
preparedStatement.executeUpdate();
}
// public void delete(String a1) throws Exception{
// Connection connection = DBUtil.getConnection();
// PreparedStatement preparedStatement = null;
// String sql = "delete from doc_list where title = ?";
// preparedStatement = connection.prepareStatement(sql);
// preparedStatement.setString(1, a1);
// preparedStatement.executeUpdate();
// }
//用户删除
public void yonghushanchu(String zhanghao) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "delete from yonghu where zhanghao = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, zhanghao);
preparedStatement.executeUpdate();
}
//登录判断
public int denglupanduan(String zhanghao, String mima) throws Exception {
//mima=DigestUtils.md5Hex(mima);
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(mima.getBytes("utf-8"));
byte[] digest = md5.digest();
mima = new BigInteger(1,digest).toString(16);
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from yonghu";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
while (rs.next()) {
if (zhanghao.equals(rs.getObject(2)) && mima.equals(rs.getObject(3))) {
//写入now表
PreparedStatement preparedStatement2 = null;
String sql2 = "insert into now (id, zhanghao,juese,bumeng) values (?,?,?,?)";
preparedStatement2 = connection.prepareStatement(sql2);
preparedStatement2.setInt(1, (int) rs.getObject(1));
preparedStatement2.setString(2, (String) rs.getObject(2));
preparedStatement2.setString(3, (String) rs.getObject(4));
preparedStatement2.setString(4, (String) rs.getObject(5));
preparedStatement2.executeUpdate();
return 1;
}
}
return 0;
}
/////////////////////////
public long getId() throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from now";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
rs.last();
String str = String.valueOf(rs.getObject(1));
int a = Integer.parseInt(str);
return a;
}
public long getShengfeng() throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from now";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
rs.last();
String str = String.valueOf(rs.getObject(2));
int a = Integer.parseInt(str);
return a;
}
public void setnow(long id,int shengfeng) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into now (id, shengfeng) values (?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setLong(1, id);
preparedStatement.setLong(2, shengfeng);
preparedStatement.executeUpdate();
}
// 登录
public void denglu(int id, int shengfeng) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into now (id, shengfeng) values (?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, id);
preparedStatement.setInt(2, shengfeng);
preparedStatement.executeUpdate();
}
public boolean xiugaimima(String mima0, String mima1) throws Exception {
if (getShengfeng() == 1) {
// 教师1
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from jiaoshi";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
while (rs.next()) {
if (getId() == (long) rs.getObject(1)) {
if (mima0.equals(rs.getObject(3))) {
String sqll = "update jiaoshi set mima=? where id=?";
preparedStatement = connection.prepareStatement(sqll);
preparedStatement.setString(1, mima1);
preparedStatement.setLong(2, getId());
preparedStatement.executeUpdate();
return true;
}
}
}
}
if (getShengfeng() == 2) {
// 学生2
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from xuesheng";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
while (rs.next()) {
if (getId() == (long) rs.getObject(1)) {
if (mima0.equals(rs.getObject(3))) {
String sqll = "update xuesheng set mima=? where id=?";
preparedStatement = connection.prepareStatement(sqll);
preparedStatement.setString(1, mima1);
preparedStatement.setLong(2, getId());
preparedStatement.executeUpdate();
return true;
}
}
}
}
return false;
}
//
public String getbianhao() throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from shengpika";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
rs.last();
long id = (long) rs.getObject(1);
long xuehao0 = id + 2022122200;
String xuehao = String.valueOf(xuehao0);
String sql1 = "update shengpika set CardId=? where id=?";
preparedStatement = connection.prepareStatement(sql1);
preparedStatement.setString(1, xuehao);
preparedStatement.setLong(2, id);
preparedStatement.executeUpdate();
return xuehao;
}
public void xingzeng(String a1, String a2, String a3, String a4, String a5, String a6, String a7, String a8, String a9, String a10, String a11, String a12, String a13, String a14)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into shengpika (CardData, CourseName, CourseTeacher, CourseID, CourseNature, Credit, CourseClass, CourseMajor,TestWay,TestData,TestCount,TestMethod,TestGrade,TestEvaluation,TestAnalysis) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, "20221222");
preparedStatement.setString(2, a1);
preparedStatement.setString(3, a2);
preparedStatement.setString(4, a3);
preparedStatement.setString(5, a4);
preparedStatement.setString(6, a5);
preparedStatement.setString(7, a6);
preparedStatement.setString(8, a7);
preparedStatement.setString(9, a8);
preparedStatement.setString(10, a9);
preparedStatement.setString(11, a10);
preparedStatement.setString(12, a11);
preparedStatement.setString(13, a12);
preparedStatement.setString(14, a13);
preparedStatement.setString(15, a14);
preparedStatement.executeUpdate();
}
// g11-增添学生
public void zengtianxuesheng(String a1, String a2, String a3, String a4, String a5, String a6, String a7, String a8)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into xuesheng (StuID, mima, StuName, sex, College, Professionals, Phone, Position) values (?,?,?,?,?,?,?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a1);
preparedStatement.setString(2, a2);
preparedStatement.setString(3, a3);
preparedStatement.setString(4, a4);
preparedStatement.setString(5, a5);
preparedStatement.setString(6, a6);
preparedStatement.setString(7, a7);
preparedStatement.setString(8, a8);
preparedStatement.executeUpdate();
}
public void zhuanyeshengcha(long id, String a1, String a2, String a3, String a4)
throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String a0="考核内容与课程教学大纲要求的符合程度:"+a1+"考核内容与课程目标达成情况的支撑度:"+a2+"考核方式与课程目标达成情况的支持度:"+a3;
String sql = "update shengpika set Professional=? , ProfessionalConclusion=? where id=?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, a0);
preparedStatement.setString(2, a4);
preparedStatement.setLong(3, id);
preparedStatement.executeUpdate();
}
public void shanchuxuesheng(long id) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "delete from xuesheng where id = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setLong(1, id);
preparedStatement.executeUpdate();
}
public void chongzhixuesheng(long id) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "update xuesheng set mima=? where id=?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, "123456");
preparedStatement.setLong(2, id);
preparedStatement.executeUpdate();
}
public String shengchenggonghao(String xueyuan) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from jiaoshi";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
rs.last();
String gonghao = (String) rs.getObject(1);
int gonghao0 = Integer.parseInt(gonghao);
if (gonghao0 == 0)
gonghao = "00001";
else {
gonghao0++;
gonghao = String.valueOf(gonghao0);
}
String gonghao000 = gonghao.substring(1);
if (xueyuan.equals("信息"))
gonghao = "01" + gonghao000;
if (xueyuan.equals("土木"))
gonghao = "02" + gonghao000;
if (xueyuan.equals("机械"))
gonghao = "03" + gonghao000;
if (xueyuan.equals("电气"))
gonghao = "04" + gonghao000;
if (xueyuan.equals("交通"))
gonghao = "05" + gonghao000;
return gonghao;
}
public void zengtianjiaoshi(String gonghao, String xingming, String zhicheng, String xueyuan) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "insert into jiaoshi (gonghao, xingming, zhicheng, xueyuan, mima) values (?,?,?,?,?)";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, gonghao);
preparedStatement.setString(2, xingming);
preparedStatement.setString(3, zhicheng);
preparedStatement.setString(4, xueyuan);
preparedStatement.setString(5, "123456");
preparedStatement.executeUpdate();
}
public void xiugaijiaoshi(String gonghao, String xingming, String zhicheng, String xueyuan) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "update jiaoshi set gonghao=?, xingming=?, zhicheng=?, xueyuan=? where xingming=?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, gonghao);
preparedStatement.setString(2, xingming);
preparedStatement.setString(3, zhicheng);
preparedStatement.setString(4, xueyuan);
preparedStatement.setString(5, xingming);
preparedStatement.executeUpdate();
}
public void shanchujiaoshi(String xingming) throws Exception {
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement = null;
String sql = "delete from jiaoshi where xingming = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, xingming);
preparedStatement.executeUpdate();
}
}
DBUtil.java:
package util;
import java.sql.*;
public class DBUtil {
public static Connection getConnection() throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jm0207?useSSL=true", "root", "123456");
return con;
}
}
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主界面</title>
</head>
<body>
<form action="role_pdd.jsp" method="post" onsubmit="return sublim()">
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<tr>
<td>身份:
<select name="pid">
<option value="1">新闻撰稿人</option>
<option value="2">普通用户</option>
<option value="3">新闻栏目管理员</option>
<option value="4">系统管理</option>
</select>
</td>
</tr><br>
账号:
<input type="text" name="zhanghao" size="20" /> <br>
密码:
<input type="password" name="mima" size="20" /> <br>
验证码:
<input type="text" value="" placeholder="请输入验证码(区分大小写)" id="text" size="20">
 <br><br>
<canvas id="canvas" width="100" height="43" onclick="dj()" style="border: 1px solid #ccc;
border-radius: 5px;"></canvas>
<br>
<input type="submit" value="登录"/>
<input type="button" value="注册" onclick="location.href='zhuce.jsp'" />
</p>
</form>
</body>
<script>
var show_num = [];
draw(show_num);
function dj() {
draw(show_num);
}
function sublim() {
var val = document.getElementById("text").value;
var num = show_num.join("");
if (val == '') {
alert('请输入验证码!');
return false;
} else if (val == num) {
document.getElementById(".input-val").val('');
draw(show_num);
return true;
} else {
alert('验证码错误!\n你输入的是: ' + val + "\n正确的是: " + num + '\n请重新输入!');
document.getElementById("text").value = '';
draw(show_num);
return false;
}
}
function draw(show_num) {
var canvas_width = document.getElementById('canvas').clientWidth;
var canvas_height = document.getElementById('canvas').clientHeight;
var canvas = document.getElementById("canvas"); //获取到canvas的对象,演员
var context = canvas.getContext("2d"); //获取到canvas画图的环境,演员表演的舞台
canvas.width = canvas_width;
canvas.height = canvas_height;
var sCode =
"A,B,C,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0,q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m";
var aCode = sCode.split(",");
var aLength = aCode.length; //获取到数组的长度
for (var i = 0; i <= 3; i++) {
var j = Math.floor(Math.random() * aLength); //获取到随机的索引值
var deg = Math.random() * 30 * Math.PI / 180; //产生0~30之间的随机弧度
var txt = aCode[j]; //得到随机的一个内容
show_num[i] = txt;
var x = 10 + i * 20; //文字在canvas上的x坐标
var y = 20 + Math.random() * 8; //文字在canvas上的y坐标
context.font = "bold 23px 微软雅黑";
context.translate(x, y);
context.rotate(deg);
context.fillStyle = randomColor();
context.fillText(txt, 0, 0);
context.rotate(-deg);
context.translate(-x, -y);
}
for (var i = 0; i <= 5; i++) { //验证码上显示线条
context.strokeStyle = randomColor();
context.beginPath();
context.moveTo(Math.random() * canvas_width, Math.random() * canvas_height);
context.lineTo(Math.random() * canvas_width, Math.random() * canvas_height);
context.stroke();
}
for (var i = 0; i <= 30; i++) { //验证码上显示小点
context.strokeStyle = randomColor();
context.beginPath();
var x = Math.random() * canvas_width;
var y = Math.random() * canvas_height;
context.moveTo(x, y);
context.lineTo(x + 1, y + 1);
context.stroke();
}
}
function randomColor() { //得到随机的颜色值
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
return "rgb(" + r + "," + g + "," + b + ")";
}
</script>
</html>
role_pdd.jsp:
<%@ page import="java.sql.*" contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="util.DBUtil" %>
<html>
<head>
<title>从index获取数据</title>
</head>
<body>
<jsp:useBean id="util" class="util.DBUtil"/>
<%
//获取前端index的登录数据
request.setCharacterEncoding("UTF-8");//编码一定设置
String pid=request.getParameter("pid");
// String username=request.getParameter("username");
String name =request.getParameter("zhanghao");
String mima=request.getParameter("mima");//取出login.jsp的值
// 新闻撰稿人
// 普通用户
// 新闻栏目管理员
// 系统管理
switch(pid) {
case "1":
// if(util.judge1(name, mima, pid)){
response.sendRedirect("1_1.jsp");break;
// }
// else {
// out.print("<script language='javaScript'> alert('密码错误');</script>");
// response.setHeader("refresh", "0;url=index.jsp");
// }
case "2": /* if(util.judge1(name, mima, pid)){*/
response.sendRedirect("1_2.jsp");break;
/*
}
else {
out.print("<script language='javaScript'> alert('密码错误');</script>");
response.setHeader("refresh", "0;url=index.jsp");
}
*/
case "3": /* if(util.judge1(name, mima,pid)){*/
response.sendRedirect("1_3.jsp");break;
/*}
else {
out.print("<script language='javaScript'> alert('密码错误');</script>");
response.setHeader("refresh", "0;url=index.jsp");
}*/
case "4": /*if(util.judge1(name, mima,pid)){*/
response.sendRedirect("1_4.jsp");break;
/*}
else {
out.print("<script language='javaScript'> alert('密码错误');</script>");
response.setHeader("refresh", "0;url=index.jsp");
}*/
// case "5": /*if(util.judge1(name, mima,pid)){*/
// response.sendRedirect("admin.jsp");break;
/*}
else {
out.print("<script language='javaScript'> alert('密码错误');</script>");
response.setHeader("refresh", "0;url=index.jsp");
}*/
}
%>
</body>
</html>
<%!
private void judgeguanli() {
}
%>
head.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="util.DBUtil"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<%
Connection head_connection = DBUtil.getConnection();
PreparedStatement head_preparedStatement = null;
ResultSet head_rs = null;
String head_sql = "select * from now";
head_preparedStatement = head_connection.prepareStatement(head_sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
head_rs = head_preparedStatement.executeQuery();
head_rs.last();
String head_str = String.valueOf(head_rs.getObject(1));
int head_id = Integer.parseInt(head_str);
String head_zhanghao=(String)head_rs.getObject(2);
String head_juese=(String)head_rs.getObject(3);
String head_bumeng=(String)head_rs.getObject(4);
%>
欢迎!
<br><input type="button" value="退出登录" onclick="location.href='index.jsp'" />
</p>
</body>
</html>
1_1.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>新闻撰稿人页面</title>
<style type="text/css">
*{font-style: "微软雅黑"}
#table{ border-collapse: collapse; margin: auto;text-align: center;}
#table th{background-color: #fff7d5;border: 1px solid black;}
#table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;}
#table a{text-decoration: none;font-weight: bold;}
#table a:hover {text-decoration: underline;}
</style>
</head>
<body class="bg">
<h2 style="text-align: center;">你好!新闻撰稿人,请选择以下操作</h2>
<br>
<div style="text-align: center;">
<input type="button" value="在线撰写稿件" onclick="location.href='1_1_1.jsp'" />
<br><br>
<input type="button" value="在线修改意见" onclick="location.href='1_1_2.jsp'" />
<br><br>
<input type="button" value="查看已写稿件及修改意见" onclick="location.href='1_1_3.jsp'" />
<br><br>
<%--浏览试卷审批卡、查询考试信息(试卷审批卡通过后生成考试信息)、新增试卷审批卡、修改试卷审批卡、删除试卷审批卡--%>
</div>
<br>
<%
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
%>
</body>
</html>
1_1_1.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<form id="1" action ="1_1_1_pdd.jsp" method="get">
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
新闻标题:
<label>
<input type="text" name="title"size="10"/>
</label>
<br><br>
关键字名称:
<label>
<input type="text" name="keyy"size="10"/>
</label>
<br><br>
撰稿人:
<label>
<input type="text" name="owner"size="10"/>
</label>
<br><br>
日期:
<label>
<input type="text" name="timee"size="10"/>
</label>
<br><br>
<tr>
<td>栏目:
<select name="col">
<option value="中心新闻">中心新闻</option>
<option value="企业环保信息">企业环保信息</option>
<option value="汽车">汽车</option>
<option value="科幻">科幻</option>
</select>
</td>
</tr>
<br><br>
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
<input type="button" value="返回菜单" onclick="location.href='1_1.jsp'" /> <br>
</p>
</form>>
</body>
</html>
1_1_1_pdd.jsp:
<%@ page contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>处理</title>
</head>
<body>
<jsp:useBean id="util" class="dao.UserDao"/>
<%
String title = request.getParameter("title");
String key = request.getParameter("keyy");
String owner = request.getParameter("owner");
String time = request.getParameter("timee");
String col = request.getParameter("col");
String str="";
// if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
// out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
// }else if(util.sfzhm(sfnum)){
// out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
// }else if(util.chachong(sfnum)){
// out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");
// }else{
util.add(title,key,owner,time,col);
out.print("<script language='javaScript'> alert('添加成功');</script>");
response.setHeader("refresh", "0;url=1_1.jsp");
%>
</body>
</html>
1_1_2.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<form id="1" action ="1_1_2_pdd.jsp" <jsp:useBean id="util" class="dao.UserDao"/>
<%
String title = request.getParameter("title");
%> method="get">
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
关键字名称:
<label>
<input type="text" name="keyy"size="10"/>
</label>
<br><br>
撰稿人:
<label>
<input type="text" name="owner"size="10"/>
</label>
<br><br>
日期:
<label>
<input type="text" name="timee"size="10"/>
</label>
<br><br>
<tr>
<td>栏目:
<select name="col">
<option value="中心新闻">中心新闻</option>
<option value="企业环保信息">企业环保信息</option>
<option value="汽车">汽车</option>
<option value="科幻">科幻</option>
</select>
</td>
</tr>
<br><br>
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
<input type="button" value="返回菜单" onclick="location.href='1_1.jsp'" /> <br>
</p>
</form>>
</body>
</html>
1_1_2_pdd.jsp:
<%@ page contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>处理</title>
</head>
<body>
<jsp:useBean id="util" class="dao.UserDao"/>
<%
String title = request.getParameter("title");
String key = request.getParameter("keyy");
String owner = request.getParameter("owner");
String time = request.getParameter("timee");
String col = request.getParameter("col");
// if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
// out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
// }else if(util.sfzhm(sfnum)){
// out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
// }else if(util.chachong(sfnum)){
// out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");
// }else{
util.update(title,key,owner,time,col);
out.print("<script language='javaScript'> alert('修改成功');</script>");
response.setHeader("refresh", "0;url=1_1.jsp");
%>
</body>
</html>
1_1_3.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1" style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=10%>修改意见</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getString(2))){
str=(String)rs.getString(2);
%>
<tr>
<td align="center"><a style="color:blue" href='1_1_3_show.jsp?title=<%=rs.getObject(2) %>'><%=rs.getObject(2)%></a></td>
<td align="center"><%=rs.getObject(7) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_1.jsp'" /> <br>
</table>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_1_3_show.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=10%>关键字</td>
<td align="center" width=10%>撰稿人</td>
<td align="center" width=10%>日期</td>
<td align="center" width=10%>栏目</td>
<td align="center" width=10%>修改意见</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><%=rs.getObject(2)%></td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(6) %></td>
<td align="center"><%=rs.getObject(7) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_1.jsp'" /> <br>
</table>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_2.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>普通用户功能页面</title>
<style type="text/css">
*{font-style: "微软雅黑"}
#table{ border-collapse: collapse; margin: auto;text-align: center;}
#table th{background-color: #fff7d5;border: 1px solid black;}
#table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;}
#table a{text-decoration: none;font-weight: bold;}
#table a:hover {text-decoration: underline;}
</style>
</head>
<body class="bg">
<h2 style="text-align: center;">你好!普通用户,请选择以下操作</h2>
<br>
<div style="text-align: center;">
<input type="button" value="浏览相应栏目新闻" onclick="location.href='1_2_1.jsp'" />
<br><br>
<input type="button" value="用户评论新闻" onclick="location.href='1_2_1_show.jsp'" />
<br><br>
<input type="button" value="查询新闻" onclick="location.href='1_2_chaxun.jsp'" />
<br><br>
<%--浏览试卷审批卡、查询考试信息(试卷审批卡通过后生成考试信息)、新增试卷审批卡、修改试卷审批卡、删除试卷审批卡--%>
</div>
<br>
<%
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
%>
</body>
</html>
1_2_1.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=10%>新闻评论</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><a style="color:blue" href='1_2_1_show.jsp?title=<%=rs.getObject(2) %>'><%=rs.getObject(2)%></a></td>
<td align="center"><a style="color:blue" href='1_2_1_comm.jsp?title=<%=rs.getObject(8) %>'><%=rs.getObject(8) %></a></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_2.jsp'" /> <br>
</p>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_2_1_comm.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=80%>新闻评论</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><%=rs.getObject(8)%></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_2_1.jsp'" /> <br>
</p>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_2_1_show.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=10%>关键字</td>
<td align="center" width=10%>撰稿人</td>
<td align="center" width=10%>日期</td>
<td align="center" width=10%>栏目</td>
<td align="center" width=10%>评论</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><%=rs.getObject(2)%></td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(6) %></td>
<td align="center"><%=rs.getObject(6) %></td>
<td align="center"><a style="color:blue" href='1_2_2.jsp?title=<%=rs.getObject(2) %>'><%=rs.getObject(6) %></a></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_2_1.jsp'" /> <br>
</p>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_2_2.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<form id="1" action ="1_2_2_pdd.jsp" method="get">
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
新闻评论:
<label>
<input type="comm" name="comm"size="10"/>
</label>
<br><br>
<br><br>
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
<input type="button" value="返回菜单" onclick="location.href='1_2.jsp'" /> <br>
</p>
</form>>
</body>
</html>
1_2_2_pdd.jsp:
<%@ page contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>处理</title>
</head>
<body>
<jsp:useBean id="util" class="dao.UserDao"/>
<%
String title = request.getParameter("title");
String key = request.getParameter("key");
String owner = request.getParameter("owner");
String time = request.getParameter("time");
String col = request.getParameter("col");
String comm = request.getParameter("comm");
// if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
// out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
// }else if(util.sfzhm(sfnum)){
// out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
// }else if(util.chachong(sfnum)){
// out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");
// }else{
util.comm(comm);
out.print("<script language='javaScript'> alert('评论成功');</script>");
response.setHeader("refresh", "0;url=1_2.jsp");
%>
</body>
</html>
1_2_chaxun.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询</title>
</head>
<body>
<form action="1_2_chaxunpd.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
输入要查询信息的新闻主题/关键字/ 撰稿人/日期(支持模糊查询):
<br> <input type="text" name="data" /> <br>
<br><input type="submit" value="提交" />
<input type="reset" value="重置" /> <br>
<br> <input type="button" value="返回菜单" onclick="location.href='1_2.jsp'" /> <br>
</p>
</form>
</body>
</html>
1_2_chaxunall:
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>详细信息</title>
</head>
<body>
<jsp:useBean id="util" class="util.DBUtil" scope="page" />
<%
String title = (String)request.getParameter("title");
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from t0";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(title.equals(rs.getObject(2)))
{
%>
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=10%>关键字</td>
<td align="center" width=10%>撰稿人</td>
<td align="center" width=10%>日期</td>
<td align="center" width=10%>新闻栏目</td>
<td align="center" width=10%>新闻修改意见</td>
<td align="center" width=10>新闻评论</td>
</tr>
<tr>
<td align="center"><%=rs.getObject(2) %></td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(6) %></td>
<td align="center"><%=rs.getObject(7) %></td>
<td align="center"><%=rs.getObject(8) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="button" name="back" onclick="javascript:window.history.back(-1);" value=返回上一页>
<input type="button" value="返回菜单" onclick="location.href='1_2.jsp'" /> <br>
</p>
</body>
</html>
1_2_chaxunall.jsp:
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询</title>
</head>
<body style="text-align:center">
查询结果
<p>
<jsp:useBean id="util" class="util.DBUtil" scope="page" />
<%
String data=(String)request.getParameter("data");
if(data==""){
out.print("<script language='javaScript'> alert('输入为空'); window.history.back(-1); </script>");
}
else
{
//新闻主题/关键字/ 撰稿人/日期
%>
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻主题</td>
<td align="center" width=10%>关键字</td>
<td align="center" width=10%>撰稿人</td>
<td align="center" width=10%>日期</td>
</tr>
<%
int i=0;
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql= " select * from doc_list where title like ? or keyy like ? or owner like ? or timee like ? ";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,"%"+data+"%");
preparedStatement.setString(2,"%"+data+"%");
preparedStatement.setString(3,"%"+data+"%");
preparedStatement.setString(4,"%"+data+"%");
rs=preparedStatement.executeQuery();
while(rs.next())
{
i++;
%>
<tr>
<td align="center"><a style="color:blue" href='1_2_chaxunall.jsp?title=<%=rs.getObject(2) %>'><%=rs.getObject(2)%></a> </td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
</tr>
<%
}
if(i==0)
{
out.print("<script language='javaScript'> alert('没有查询到有关信息'); window.history.back(-1); </script>");
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
}
%>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>
1_3.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>新闻栏目管理员功能页面</title>
<style type="text/css">
*{font-style: "微软雅黑"}
#table{ border-collapse: collapse; margin: auto;text-align: center;}
#table th{background-color: #fff7d5;border: 1px solid black;}
#table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;}
#table a{text-decoration: none;font-weight: bold;}
#table a:hover {text-decoration: underline;}
</style>
</head>
<body class="bg">
<h2 style="text-align: center;">你好!新闻栏目管理员,请选择以下操作</h2>
<br>
<div style="text-align: center;">
<input type="button" value="管理待发与已发新闻" onclick="location.href='1_3_1.jsp'" />
<br><br>
<input type="button" value="管理新闻评论回复" onclick="location.href='1_3_1.jsp'" />
<br><br>
<%--浏览试卷审批卡、查询考试信息(试卷审批卡通过后生成考试信息)、新增试卷审批卡、修改试卷审批卡、删除试卷审批卡--%>
</div>
<br>
<%
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
%>
</body>
</html>
1_3_1.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=7%>添加修改意见</td>
<td align="center" width=7%>删除该新闻</td>
<td align="center" width=10%>新闻评论</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><a style="color:blue" href='1_3_1_show.jsp?title=<%=rs.getObject(2) %>'><%=rs.getObject(2)%></a></td>
<td align="center"><a style="color:blue" href='1_3_1_update.jsp?title=<%=rs.getObject(2) %>'>添加修改意见</a></td>
<td align="center"><a style="color:blue" href='1_3_1_delete.jsp?title=<%=rs.getObject(2) %>'>删除该新闻</a></td>
<td align="center"><a style="color:blue" href='1_3_1_comm.jsp?title=<%=rs.getObject(2) %>'><%=rs.getObject(8) %></a></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_3.jsp'" /> <br>
</p>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_3_1_comm.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=70%>新闻评论</td>
<td align="center" width=7%>删除</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><%=rs.getObject(8)%></td>
<td align="center"><a style="color:blue" href='1_3_1_comm_delete.jsp?comm=<%=rs.getObject(8) %>'>删除该评论</a></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_3_1.jsp'" /> <br>
</p>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_3_1_comm_delete.jsp:
<%@ page contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>删除</title>
</head>
<body>
<jsp:useBean id="util" class="dao.UserDao"/>
<%
String comm = request.getParameter("comm");
// String owner = request.getParameter("owner");
// String place = request.getParameter("place");
// if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
// out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
// }else if(util.sfzhm(sfnum)){
// out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
// }else if(util.chachong(sfnum)){
// out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");
// }else{
util.comm_delete(comm);
out.print("<script language='javaScript'> alert('删除成功');</script>");
response.setHeader("refresh", "0;url=1_3_1.jsp");
%>
</body>
</html>
1_3_1_delete.jsp:
<%@ page contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>删除</title>
</head>
<body>
<jsp:useBean id="util" class="dao.UserDao"/>
<%
String title = request.getParameter("title");
// String owner = request.getParameter("owner");
// String place = request.getParameter("place");
// if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
// out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
// }else if(util.sfzhm(sfnum)){
// out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
// }else if(util.chachong(sfnum)){
// out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");
// }else{
util.delete(title);
out.print("<script language='javaScript'> alert('删除成功');</script>");
response.setHeader("refresh", "0;url=1_3.jsp");
%>
</body>
</html>
1_3_1_show.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=10%>新闻标题</td>
<td align="center" width=10%>关键字</td>
<td align="center" width=10%>撰稿人</td>
<td align="center" width=10%>日期</td>
<td align="center" width=10%>栏目</td>
</tr>
<%
String str="";
Connection connection = DBUtil.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from doc_list";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(!str.equals(rs.getObject(2))){
str=(String)rs.getObject(2);
%>
<tr>
<td align="center"><%=rs.getObject(2)%></td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(6) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
}
%>
<input type="button" value="返回菜单" onclick="location.href='1_3_1.jsp'" /> <br>
</p>
<script>
function del(){
var r = confirm("确定要删除吗?")
if (r == true) {
return true;
} else {
return false;
}
}
</script>
</body>
</html>
1_3_1_update.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%@ include file="head.jsp" %>
<form id="1" action ="1_3_1_update_pdd.jsp" method="get">
<p style="text-align: center; color: black; font-family: 宋体; font-size: 20px">
修改意见:
<label>
<input type="com" name="time"size="10"/>
</label>
<br><br>
<br><br>
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
<input type="button" value="返回菜单" onclick="location.href='1_3_1.jsp'" /> <br>
</p>
</form>>
</body>
</html>
1_3_1_update_pdd.jsp:
<%@ page contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>处理</title>
</head>
<body>
<jsp:useBean id="util" class="dao.UserDao"/>
<%
String title = request.getParameter("title");
String key = request.getParameter("key");
String owner = request.getParameter("owner");
String time = request.getParameter("time");
String com = request.getParameter("com");
// if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
// out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
// }else if(util.sfzhm(sfnum)){
// out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
// }else if(util.chachong(sfnum)){
// out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");
// }else{
util.com_update(title,com);
out.print("<script language='javaScript'> alert('给出修改意见成功');</script>");
response.setHeader("refresh", "0;url=1_3_1.jsp");
%>
</body>
</html>
1_4.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>系统管理功能页面</title>
<style type="text/css">
*{font-style: "微软雅黑"}
#table{ border-collapse: collapse; margin: auto;text-align: center;}
#table th{background-color: #fff7d5;border: 1px solid black;}
#table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;}
#table a{text-decoration: none;font-weight: bold;}
#table a:hover {text-decoration: underline;}
</style>
</head>
<body class="bg">
<h2 style="text-align: center;">你好!系统管理员,请选择以下操作</h2>
<br>
<div style="text-align: center;">
<input type="button" value="用户注册" onclick="location.href='1_4_1.jsp'" />
<br><br>
<input type="button" value="用户权限管理" onclick="location.href='1_4_2.jsp'" />
<br><br>
<input type="button" value="新闻栏目管理" onclick="location.href='1_4_3.jsp'" />
<br><br>
<%--浏览试卷审批卡、查询考试信息(试卷审批卡通过后生成考试信息)、新增试卷审批卡、修改试卷审批卡、删除试卷审批卡--%>
</div>
<br>
<%
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
%>
</body>
</html>