集成公告、新闻发布,新闻、公告均可批量删除

This commit is contained in:
FJY
2017-11-18 20:29:56 +08:00
parent a303f56e12
commit c98fac69af
27 changed files with 1659 additions and 2 deletions

44
WebRoot/notice/add.html Normal file
View File

@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<title>公告</title>
<meta name="viewport"
content="width=100%; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
</head>
<style>
h1 {
text-align: center;
}
.content {
height: 70px;
}
.center {
width: 500px;
height: 200px;
margin: auto;
}
</style>
<body>
<form method="post" action="add.jsp">
<h1>增加公告</h1>
<div class="center">
<br />
<p>公告内容</p>
<textarea name="a3" rows="8" name='t2' cols="20"
" style="width: 375px; "></textarea>
<br /> <br /> <font>公告作者</font><input name="a4" size="10"
type="text" style="width: 299px; " /> <br /> <input type="submit"
class="btcss2" value="增加" />
</form>
</div>
</body>
</head>
</html>

50
WebRoot/notice/add.jsp Normal file
View File

@@ -0,0 +1,50 @@
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.sql.*"%>
<HTML>
<BODY>
<%
request.setCharacterEncoding("utf-8");
// String k2=request.getParameter("a2"); if(k2==null){k2="";} k2=codeString(k2);
String k3 = request.getParameter("a3");
if (k3 == null || k3 == "") {
k3 = null;
}
String k4 = request.getParameter("a4");
if (k4 == null) {
k4 = "";
}
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException event) {
out.print("驱动异常");
}
try {
if (k3 == null) {
out.print("公告内容不能为空");
response.setHeader("refresh", "5;url=../issue_page.jsp");
} else {
Connection con = null;
Statement sql = null;
String condition = null;
condition = "INSERT INTO notice(公告内容,公告作者) VALUES('" + k3 + "','" + k4 + "')";
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8", "root", "");
sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
sql.executeUpdate(condition);
con.close();
sql.close();
out.print("公告发布成功!");
response.setHeader("refresh", "2;url=../mainframe.jsp");
out.print("2秒后自动返回...");
}
} catch (SQLException event) {
out.print("发布公告失败");
response.setHeader("refresh", "5;url=../mainframe.jsp");
out.print("5秒后自动返回...");
}
%>
</BODY>
</HTML>

43
WebRoot/notice/delete.jsp Normal file
View File

@@ -0,0 +1,43 @@
<%@ page contentType="text/html;charset=UTf-8" %>
<%@ page import="java.sql.*" %>
<%! //处理字符串的方法:
public String codeString(String s)
{ String str=s;
try{byte b[]=str.getBytes("ISO-8859-1");
str=new String(b); return str;
} catch(Exception e) { return str; }
}
%>
<HTML>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="2;url=index.jsp">
<title></title>
</head>
<BODY>
<%
String k1=request.getParameter("t1"); if(k1==null){k1="";} k1=codeString(k1);
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException event){out.print("暂时无法访问");}
String condition=null;
out.print(k1);
condition="DELETE from 公告表1 WHERE 公告编号 = '"+k1+"'";
try {
con=DriverManager.getConnection("jdbc:mysql://localhost/公告栏","root","123456");
sql=con.createStatement();
sql.executeUpdate(condition);
out.print("成功删除!</a>");
response.setHeader("refresh","5;url=index.jsp");
out.print("5秒后自动返回...");
sql.close();
con.close();
} catch(SQLException event)
{
out.print("删除失败");
response.setHeader("refresh","5;url=index.jsp");
out.print("5秒后自动返回...");}
%>
</BODY></HTML>

80
WebRoot/notice/index.jsp Normal file
View File

@@ -0,0 +1,80 @@
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.sql.*"%>
<%!//处理字符串的方法:
public String codeString(String s) {
String str = s;
try {
byte b[] = str.getBytes("ISO-8859-1");
str = new String(b);
return str;
} catch (Exception e) {
return str;
}
}%>
<HTML>
<style>
.zczi {
float: right;
}
.zczi2 {
float: left;
}
</style>
<div align=center>
<b>公告栏</b>
</div>
<p></p>
<center>
<table border>
<tr>
<th bgcolor=#FFFFFF><marquee direction=up height=300 width=500
id=m onmouseout=m.start() onMouseOver=m.stop() scrollamount=2
align="center">
<font size=2>
<p></p>
<p>
<%
Connection con;
Statement sql;
ResultSet rs;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
out.print("驱动异常");
}
try {
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8", "root", "");
sql = con.createStatement();
String condition = null;
condition = "SELECT 公告内容,公告时间 FROM notice";
rs = sql.executeQuery(condition);
while (rs.next()) //输出查询结果
{
out.print("<div><span class='zczi2'>" + rs.getString(1) + "</span>");
out.print("<span class='zczi'>" + rs.getString(2) + "</span></div>");
out.println("<br/>");
out.println("<br/>");
}
con.close();
sql.close();
rs.close();
} catch (SQLException e1) {
out.print("无法查询记录");
}
%>
</p >
</p>
</font>
</marquee></th>
</table>
<center>
<a href=add.html>增加公告</a> <a href=selectupdate.jsp>修改公告</a> <a
href=selectdelete.jsp>删除公告</a>
<BODY>
</BODY>
</HTML>

View File

@@ -0,0 +1,56 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.sql.*" %>
<%! //处理字符串的方法:
public String codeString(String s)
{ String str=s;
try{byte b[]=str.getBytes("ISO-8859-1");
str=new String(b);
return str;
} catch(Exception e) { return str; }
}
%>
<HTML>
<BODY>
<%
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName("com.mysql.jdbc.Driver");
} catch(ClassNotFoundException e){out.print("暂时无法访问");}
try {
con=DriverManager.getConnection("jdbc:mysql://localhost/公告栏","root","123456");
sql=con.createStatement();
String condition=null;
condition="SELECT * FROM 公告表1";
rs=sql.executeQuery(condition);
out.print("<Table Border align='center'>");
out.print("<TR>");
out.print("<TH width=100 >"+"公告编号");
out.print("<TH width=100 >"+"公告内容");
out.print("<TH width=100 >"+"公告作者");
out.print("<TH width=100 >"+"公告时间");
out.print("</TR>");
while(rs.next()) //输出查询结果
{ out.print("<TR>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(1)+"</TD>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(2)+"</TD>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(3)+"</TD>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(4)+"</TD>");
out.print("</TR>") ;
}
out.print("</Table>");
con.close();
}
catch(SQLException e1) {out.print("无法查询记录");}
%>
<form 公告编号="form2" method="post" action="delete.jsp">
<div align='center'>
请输入你要删除的公告编号<input name="t1" size="11" type="text">
<input type="submit" class="btcss2" value="提交删除" /><br />
</div>
</form>
</BODY>
</HTML>

View File

@@ -0,0 +1,58 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.sql.*" %>
<%! //处理字符串的方法:
public String codeString(String s)
{ String str=s;
try{str=new String(s.getBytes("ISO8859-1"),"UTF-8");
return str;
} catch(Exception e) { return str; }
}
%>
<HTML>
<BODY>
<%
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName("com.mysql.jdbc.Driver");
} catch(ClassNotFoundException e){out.print("暂时无法访问");}
try {
con=DriverManager.getConnection("jdbc:mysql://localhost/公告栏","root","123456");
sql=con.createStatement();
String condition=null;
condition="SELECT * FROM 公告表1";
rs=sql.executeQuery(condition);
out.print("<Table Border align='center'>");
out.print("<TR>");
out.print("<TH width=100 >"+"公告编号");
// out.print("<TH width=100 >"+"公告题目");
out.print("<TH width=100 >"+"公告内容");
out.print("<TH width=100 >"+"公告作者");
out.print("<TH width=100 >"+"公告时间");
out.print("</TR>");
while(rs.next()) //输出查询结果
{ out.print("<TR>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(1)+"</TD>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(2)+"</TD>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(3)+"</TD>");
out.print("<TD height=100 vertical-align:top>"+rs.getString(4)+"</TD>");
//out.print("<TD height=100 vertical-align:top>"+rs.getString(5)+"</TD>");
out.print("</TR>") ;
}
out.print("</Table>");
con.close();
}
catch(SQLException e1) {out.print("无法查询记录");}
%>
<form 公告编号="form2" method="post" action="update.jsp">
<div align="center">
请输入你要修改的公告编号<br /><input name="a1" size="11" type="text"><br/>
请输入你要修改的公告内容:<br /><textarea name="a2" cols="40" rows="5" type="text"></textarea>
<br /><br />
<input type="submit" class="btcss2" value="提交修改" /><br />
</div>
</form>
</BODY>
</HTML>

37
WebRoot/notice/update.jsp Normal file
View File

@@ -0,0 +1,37 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.sql.*" %>
<HTML>
<head>
</head>
<BODY>
<%
request.setCharacterEncoding("utf-8");
String k1=request.getParameter("a1"); //if(k1==null){k1="";} k1=codeString(k1);
String k2=request.getParameter("a2"); //if(k2==null){k2="";} k2=codeString(k2);
Connection con=null;
Statement sql=null;
ResultSet rs=null;
String condition=null;
condition="UPDATE 公告表1 SET 公告内容='"+k2+"' WHERE 公告编号='"+k1+"' ";
try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException event){out.print("驱动异常");}
try {
con=DriverManager.getConnection("jdbc:mysql://localhost/公告栏","root","123456");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
sql.executeUpdate(condition);
con.close();
out.print("公告修改成功!</a>");
response.setHeader("refresh","5;url=index.jsp");
out.print("5秒后自动返回...");
} catch(SQLException event)
{
out.print("修改公告失败");
response.setHeader("refresh","5;url=index.jsp");
out.print("5秒后自动返回...");
}
%>
</BODY></HTML>