集成公告、新闻发布,新闻、公告均可批量删除
This commit is contained in:
46
WebRoot/news/add.html
Normal file
46
WebRoot/news/add.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Language" content="zh-CN">
|
||||
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<font>新闻题目</font><input name="t1" size="20" type="text"
|
||||
style="width: 317px; " /> <br /> <br />
|
||||
<p>新闻内容</p>
|
||||
<textarea rows="20" name='t2' cols="60"></textarea>
|
||||
<br /> <br /> <font>新闻来源</font><input name="t3" size="10"
|
||||
type="text" style="width: 290px; " /> <br /> <br /> <input
|
||||
type="submit" class="btcss2" value="增加" />
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</head>
|
||||
</HTML>
|
||||
68
WebRoot/news/add.jsp
Normal file
68
WebRoot/news/add.jsp
Normal file
@@ -0,0 +1,68 @@
|
||||
<%@ 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>
|
||||
<head>
|
||||
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<BODY>
|
||||
<%
|
||||
String k1 = request.getParameter("t1");
|
||||
if (k1 == null) {
|
||||
k1 = "";
|
||||
}
|
||||
k1 = codeString(k1);
|
||||
String k2 = request.getParameter("t2");
|
||||
if (k2 == null) {
|
||||
k2 = "";
|
||||
}
|
||||
k2 = codeString(k2);
|
||||
String k3 = request.getParameter("t3");
|
||||
if (k3 == null) {
|
||||
k3 = "";
|
||||
}
|
||||
k3 = codeString(k3);
|
||||
//String k4=request.getParameter("a4"); if(k4==null){k4="";} k4=codeString(k4);
|
||||
//String k5=request.getParameter("a5"); if(k5==null){k5="";} k5=codeString(k5);
|
||||
|
||||
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException event) {
|
||||
out.print("驱动异常");
|
||||
}
|
||||
try {
|
||||
Connection con = null;
|
||||
Statement sql = null;
|
||||
String condition = null;
|
||||
condition = "INSERT INTO tb_news(newtitle,newstext,newsfrom) VALUES('" + k1 + "','" + k2 + "','" + k3
|
||||
+ "')";
|
||||
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);
|
||||
out.print("新闻发布成功!");
|
||||
out.print("2秒后自动返回...");
|
||||
con.close();
|
||||
sql.close();
|
||||
response.setHeader("refresh", "2;url=../mainframe.jsp");
|
||||
} catch (SQLException event) {
|
||||
out.print("发布新闻失败");
|
||||
response.setHeader("refresh", "5;url=../mainframe.jsp");
|
||||
out.print("5秒后自动返回...");
|
||||
}
|
||||
%>
|
||||
</BODY>
|
||||
</HTML>
|
||||
64
WebRoot/news/deleteinput.jsp
Normal file
64
WebRoot/news/deleteinput.jsp
Normal file
@@ -0,0 +1,64 @@
|
||||
<%@ 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>
|
||||
<%
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
out.print("暂时无法访问");
|
||||
}
|
||||
try {
|
||||
Connection con;
|
||||
Statement sql;
|
||||
ResultSet rs;
|
||||
con = DriverManager.getConnection("jdbc:mysql://localhost/news", "root", "123456");
|
||||
sql = con.createStatement();
|
||||
String condition = null;
|
||||
condition = "SELECT * FROM newstable1";
|
||||
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=200 >" + "新闻内容");
|
||||
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>");
|
||||
sql.close();
|
||||
rs.close();
|
||||
con.close();
|
||||
} catch (SQLException e1) {
|
||||
out.print("无法查询记录");
|
||||
}
|
||||
%>
|
||||
<form method="post" action="deleterun.jsp">
|
||||
<div align='center'>
|
||||
请输入你要删除的新闻编号<input name="t1" size="11" type="text"> <input
|
||||
type="submit" class="btcss2" value="提交删除" /><br />
|
||||
</div>
|
||||
</form>
|
||||
</BODY>
|
||||
</HTML>
|
||||
58
WebRoot/news/deleterun.jsp
Normal file
58
WebRoot/news/deleterun.jsp
Normal 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 {
|
||||
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=../issue_page.jsp">
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<BODY>
|
||||
<%
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String s[] = request.getParameterValues("chk");
|
||||
String table_name = request.getParameter("tablename");
|
||||
String colname = request.getParameter("colname");
|
||||
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
out.print("驱动异常");
|
||||
}
|
||||
try {
|
||||
Connection con = null;
|
||||
Statement sql = null;
|
||||
con = DriverManager.getConnection(
|
||||
"jdbc:mysql://localhost/db_school?useUnicode=true&characterEncoding=utf-8", "root", "");
|
||||
sql = con.createStatement();
|
||||
if (s != null) {
|
||||
for (int i = 0; i < s.length; i++) {
|
||||
String text = "DELETE from " + table_name + " WHERE " + colname + " = '" + s[i] + "'";
|
||||
sql.executeUpdate(text);
|
||||
}
|
||||
}
|
||||
sql.close();
|
||||
con.close();
|
||||
out.print("成功删除");
|
||||
response.setHeader("refresh", "2;url=../issue_page.jsp");
|
||||
out.print("2秒后自动返回...");
|
||||
} catch (SQLException event) {
|
||||
out.print("删除新闻失败,以下信息供开发者查看,查看传值是否正常");
|
||||
/*response.setHeader("refresh", "5;url=../issue_page.jsp"); */
|
||||
out.print(colname);
|
||||
out.print(table_name);
|
||||
}
|
||||
%>
|
||||
</BODY>
|
||||
</HTML>
|
||||
61
WebRoot/news/index.jsp
Normal file
61
WebRoot/news/index.jsp
Normal file
@@ -0,0 +1,61 @@
|
||||
<%@ 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>
|
||||
<div align=center>
|
||||
<b>新闻发布专栏</b>
|
||||
</div>
|
||||
<p></p>
|
||||
<center>
|
||||
|
||||
<%
|
||||
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 newsid,newtitle,addTime FROM newstable";
|
||||
rs=sql.executeQuery(condition);
|
||||
//String k1=rs.getString(1);
|
||||
out.print("<table Border align='center' >");
|
||||
out.print("<tr>");
|
||||
out.print("<th>新闻标题</th>");
|
||||
out.print("<th>新闻时间</th>");
|
||||
out.print("<th>");
|
||||
out.print("</tr>");
|
||||
while(rs.next()) //输出查询结果
|
||||
{
|
||||
|
||||
out.print("<tr>");
|
||||
out.println("<TD><div align='center' class='zczi'>"+rs.getString(2)+"</div></TD>");
|
||||
out.print("<TD><div align='right' class='zczi'>"+rs.getString(3)+"</div></TD>");
|
||||
out.print("<TD><div align='center'><strong><a href='show.jsp?newsid="+rs.getString(1)+"' class='zczi'>查看</a></div></TD>");
|
||||
out.print("</tr>");
|
||||
|
||||
}
|
||||
out.print("</table>");
|
||||
con.close();
|
||||
}
|
||||
catch(SQLException e1) {out.print("无法查询记录");} %></p>
|
||||
</p>
|
||||
|
||||
<center>
|
||||
|
||||
<a href=add.html>增加新闻</a>
|
||||
<a href=updatechoose.jsp>修改新闻</a>
|
||||
<a href=deleteinput.jsp>删除新闻</a>
|
||||
<BODY >
|
||||
</BODY>
|
||||
</HTML>
|
||||
51
WebRoot/news/show.jsp
Normal file
51
WebRoot/news/show.jsp
Normal file
@@ -0,0 +1,51 @@
|
||||
<%@ 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>
|
||||
<%
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String k1=request.getParameter("newsid"); if(k1==null){k1="";}
|
||||
|
||||
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 newtitle,newstext,newsfrom,addTime FROM tb_news";
|
||||
rs=sql.executeQuery(condition);
|
||||
|
||||
while(rs.next()) //输出查询结果
|
||||
{
|
||||
|
||||
out.print("<div align=center>新闻题目: "+rs.getString(1)+"</div>");
|
||||
|
||||
out.println("<br/>");
|
||||
out.println("<div align=center>新闻内容:"+rs.getString(2)+"</div>");
|
||||
|
||||
out.println("<div align=center>新闻来源:"+rs.getString(3)+"</div>");
|
||||
|
||||
out.println("<div align=center>新闻时间:"+rs.getString(4)+"</div>");
|
||||
|
||||
|
||||
}
|
||||
|
||||
con.close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(SQLException e1) {out.print("无法查询记录");}
|
||||
%>
|
||||
|
||||
49
WebRoot/news/updatechoose.jsp
Normal file
49
WebRoot/news/updatechoose.jsp
Normal file
@@ -0,0 +1,49 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%@ page import="java.sql.*" %>
|
||||
|
||||
<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/news","root","123456");
|
||||
sql=con.createStatement();
|
||||
String condition=null;
|
||||
condition="SELECT * FROM newstable1";
|
||||
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=200 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 method="post" action="updeterun.jsp">
|
||||
请输入你要修改的新闻编号<br /><input name="t1" size="11" ><br><br/>
|
||||
请输入你要修改的新闻内容:<br /><textarea name="t2" cols="40" rows="5" type="text" style="height: 255px; width: 727px; "></textarea>
|
||||
<br /><br />
|
||||
<input type="submit" class="btcss2" value="提交修改" /><br />
|
||||
</form>
|
||||
</BODY>
|
||||
</HTML>
|
||||
43
WebRoot/news/updeterun.jsp
Normal file
43
WebRoot/news/updeterun.jsp
Normal 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{
|
||||
str=new String(s.getBytes("ISO8859-1"),"UTF-8");
|
||||
return str;
|
||||
} catch(Exception e) { return str; }
|
||||
}
|
||||
--%>
|
||||
<HTML>
|
||||
|
||||
<BODY>
|
||||
<%
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String k1=request.getParameter("t1"); //if(k1==null){k1="";} k1=codeString(k1);
|
||||
String k2=request.getParameter("t2"); //if(k1==null){k2="";} k1=codeString(k2);
|
||||
out.print(k1);
|
||||
out.print(k2);
|
||||
Connection con=null;
|
||||
Statement sql=null;
|
||||
ResultSet rs=null;
|
||||
try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException event){out.print("暂时无法访问");}
|
||||
String condition=null;
|
||||
condition="UPDATE newstable1 SET newstext='"+k2+"' WHERE newsid='"+k1+"' ";
|
||||
try {
|
||||
con=DriverManager.getConnection("jdbc:mysql://localhost/news","root","123456");
|
||||
sql=con.createStatement();
|
||||
sql.executeUpdate(condition);
|
||||
out.print(k2);
|
||||
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>
|
||||
Reference in New Issue
Block a user