?? newsedit2.jsp
字號:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*" %>
<%!
String id = "";
String title = "";
String title1 = "";
String content = "";
String keyw = "";
String author = "";
int currid = 0;
String sql = "";
ResultSet rs = null;
Statement stmt= null;
Connection conn=null;
%>
<link rel="stylesheet" type="text/css" href="news.css">
<%
request.setCharacterEncoding("GBK");
try{
String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Program Files/Apache Group/Tomcat 4.1/webapps/examples/jsp/db1.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection(strurl);
stmt=conn.createStatement();
}
catch(Exception e)
{
out.println("語句輸入錯誤!");
}
// 下面主要是為了進行顯示
if(request.getParameter("id") != null) {
id = request.getParameter("id");
sql="select * from news where id=" + request.getParameter("id");
rs = stmt.executeQuery( sql );
if(rs.next()) {
title1 = rs.getString("title");
content = rs.getString("content");
keyw = rs.getString("keyw");
author = rs.getString("author");
rs.close();
%>
<form name=form1 method="post" action="savenews.jsp">
<input value="<%=id%>" type=hidden name=id>
<P align="center">標 題:<INPUT size=95 name=title value=<%=title1%>></P>
<P align="center">內 容:<TEXTAREA cols=73 name=body rows=15><%=content%></TEXTAREA></P>
<P align="center">關鍵字:<INPUT size=25 name=keyw value=<%=keyw%>>
作者:
<INPUT size=25 name=author value=<%=author%>>
<p align="center">
<INPUT class=buttonface type=submit value=" 確 定 ">
<INPUT class=buttonface type=reset value=" 清 除 "></p>
</form>
<%
} else {
out.println("<hr>");
out.println("<center>非法的id號!</center>");
out.println("<hr>");
}
}
%>
<html>
<body bgcolor=lightyellow>
<P align="center"><a href="newsedit.jsp">編輯新聞</a> <a href="default.jsp">查看新聞</a>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -