📄 edit.jsp
字号:
<%@ include file="check.jsp"%>
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<html>
<script language="javaScript">
function check()
{
if(myform.title.value=="")
{
alert("请输入新闻的标题!");
return false;
}
if(myform.content.value=="")
{
alert("请输入新闻的内容!");
return false;
}
if(myform.author.value=="")
{
alert("请输入新闻的作者!");
return false;
}
}
</script>
<body>
<center>
<font color="red"><h2>编辑新闻</h2></font>
<div align="right"><font size="2"><a href="manage.jsp">返回管理页面</a></font></div>
<hr>
<%
String editid="";
String title="";
String content="";
String author="";
String pubdate="";
if(request.getParameter("editid")!=null)
editid=request.getParameter("editid");
String sql="select * from news where id="+editid;
ResultSet rs=null;
rs=conn.executeQuery(sql);
if(rs.next())
{
title=rs.getString("title");
content=rs.getString("content");
author=rs.getString("author");
pubdate=rs.getString("pubdate");
%>
<form name="myform" method="post" action="update.jsp" onSubmit="return check()">
<input type="hidden" name="editid" value="<%=editid%>">
<table border="1" borderColorDark="#ffffec" borderColorLight="#5e5e00" width="70%">
<tr bgcolor="#f7f7f7">
<td width=10%>标题:</td>
<td><input type="text" name="title" size="65%" value="<%=title%>"></td>
<tr bgcolor="#f7f7f7">
<td>内容:</td>
<td><textarea name="content" cols="63%" rows="13%"><%=content%></textarea></td>
<tr bgcolor="#f7f7f7">
<td>作者:</td>
<td><input type="text" name="author" size="65%" value="<%=author%>"></td>
<tr bgcolor="#f7f7f7">
<td colspan="2" align="center">
<input type="submit" value="修改">
<input type="reset" value="清空">
</td>
</table>
</form>
<%
}
else
{
%>
<h2>对不起,没有相关的新闻!</h2>
<%
}
rs.close();
conn.close();
%>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -