📄 manage.jsp
字号:
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<%@ include file="top.htm"%>
<%@ include file="check.jsp"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<script language="javaScript">
function detail(id)
{
window.open('detail.jsp?id='+id,'infoWin','height=400,width=600,scrollbars=yes,resizable=yes');
}
</script>
<%
String sql="";
String type="";
String key="";
request.setCharacterEncoding("gb2312");
if(request.getParameter("delid")!=null)
{
sql="delete from news where id="+request.getParameter("delid");
conn.executeUpdate(sql);
conn.close();
}
if(request.getParameter("stype")!=null)
type=request.getParameter("stype");
if(request.getParameter("skey")!=null)
key=request.getParameter("skey");
ResultSet rs=null;
sql="select * from news";
if(type!=null && key!=null && !type.equals("") && !key.equals(""))
sql += " where "+type+" like '%"+key+"%'";
sql+=" order by pubdate desc";
rs=conn.executeQuery(sql);
%>
<p><center><font color="red" size="5"><strong>新闻管理</strong></font></center>
<div align="right"><font size="2"><a href="logout.jsp">管理员退出</a></font></div>
<center>
<p><font size="2">
<form method="post" action="manage.jsp">
请选择查询类别:
<select name="stype">
<option value="title" <%if(type!=null) if(type.equals("title")) out.print("selected");%>>按标题查询</option>
<option value="content" <%if(type!=null) if(type.equals("content")) out.print("selected");%>>按内容查询</option>
<option value="author" <%if(type!=null) if(type.equals("author")) out.print("selected");%>>按作者查询</option>
<option value="pubdate" <%if(type!=null) if(type.equals("pubdate")) out.print("selected");%>>按日期查询</option>
</select>
请输入查询关键字:
<input type="text" name="skey">
<input type="submit" value="查询">
</form></font>
<table border="1" borderColorDark="#ffffec" borderColorLight="#5e5e00" width="95%">
<%
int num=1;
while(rs.next())
{
String id=rs.getString("id");
if(num%2==1)
out.println("<tr bgcolor='#FFFFCC'>");
else
out.println("<tr bgcolor='#f7f7f7'>");
out.println("<td><a href='javaScript:detail("+id+")'>"+rs.getString("title")+"</a> ");
out.println(rs.getString("author")+" 发布于 "+rs.getString("pubdate")+"</td>");
out.println("<td align='right'><a href='edit.jsp?editid="+id+"'>编辑</a></td>");
out.println("<td align='right'><a href='manage.jsp?delid="+id+"'>删除</a></td>");
num++;
}
rs.close();
conn.close();
%>
</table>
</center>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -