帖子太长,占据了3层楼,请各位解决问题
listperson.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ page import="java.sql.*"%><jsp:directive.page import="java.sql.Date" /><jsp:directive.page import="java.sql.Timestamp" /><jsp:directive.page import="java.sql.SQLException"/><style type="text/css">body, td, th, input {font-size:12px; text-align:center; }</style><% Connection conn = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:orcl", "scott", "Admin168"); stmt = conn.createStatement(); rs = stmt.executeQuery("select * from person");%><form action="operateperson.jsp" method="get"> <table align=right> <tr> <td><a href="addperson.jsp">新建人员资料</a></td> </tr> </table> <br> <br> <table bgcolor="#cccccc" cellpadding="1" cellspacing="1" width="80%" align="center"> <tr bgcolor="#dddddd"> <th></th> <th>ID</th> <th>姓名</th> <th>英文名</th> <th>性别</th> <th>年龄</th> <th>生日</th> <th>备注</th> <th>记录创建时间</th> <th>操作</th> </tr> <% //遍历结果集,rs.next()返回结果集中是否还有下一条记录,如果有,自动滚动到下一条记录并返回true while (rs.next()) { int id = rs.getInt("id"); String name = rs.getString("name"); String englishname = rs.getString("english_name"); String sex = rs.getString("sex"); int age = rs.getInt("age"); Date birthday = rs.getDate("birthday"); String description = rs.getString("description"); Timestamp createtime = rs.getTimestamp("create_time"); out.println("<tr bgcolor='#ffffff'>"); out.println(" <td><input type='checkbox' name='id' value='" + id + "'></td>"); out.println(" <td align='center'>" + id + "</td>"); out.println(" <td align='center'>" + name + "</td>"); out.println(" <td align='center'>" + englishname + "</td>"); out.println(" <td align='center'>" + sex + "</td>"); out.println(" <td align='center'>" + age + "</td>"); out.println(" <td align='center'>" + birthday + "</td>"); out.println(" <td align='center'>" + description + "</td>"); out.println(" <td align='center'>" + createtime + "</td>"); out.println(" <td align='center'>"); out.println(" <a href='operateperson.jsp?action=del&id=" + id + "' onclick='return confirm(\"确定删除记录吗?\")'>删除</a>"); out.println(" <a href='operateperson.jsp?action=edit&id=" + id + "'>修改</a>"); out.println(" </td>"); out.println("</tr>"); } %> </table> <table align="left"> <tr> <td> <input type='hidden' value='del' name='action'> <a href='#' onclick="var array=document.getElementsByName('id'); for(var i=0; i<array.length; i++){array[i].checked=true;}">全选</a> <a href='#' onclick="var array=document.getElementsByName('id'); for(var i=0; i<array.length; i++){array[i].checked=false;}">取消全选</a> <input type='submit' onclick="return confirm('即将删除所选择的记录。是否删除?');" value='删除'> </td> </tr> </table></form><% } catch (Exception e) { e.printStackTrace(); } finally { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (conn != null) conn.close(); }%><% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><base href="<%=basePath%>"><title>My JSP 'listperson.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!-- <link rel="stylesheet" type="text/css" href="styles.css"> --></head><body></body></html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><% String action = (String) request.getAttribute("action"); String id = (String) request.getAttribute("id"); String name = (String) request.getAttribute("name"); String englishname = (String) request.getAttribute("englishname"); String age = (String) request.getAttribute("age"); String sex = (String) request.getAttribute("sex"); String birthday = (String) request.getAttribute("birthday"); String description = (String) request.getAttribute("description"); String createtime = (String) request.getAttribute("create_time"); boolean isEdit = "edit".equals(action);%><% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><base href="<%=basePath%>"><style type="text/css">body,td { font-size: 12px;}</style><title><%=isEdit ? "修改人员资料" : "新建人员资料"%></title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!-- <link rel="stylesheet" type="text/css" href="styles.css"> --></head><body> <form action="operateperson.jsp" method="post"> <script type="text/javascript" src="js/calendar.js"></script> <input type="hidden" name="action" value="<%=isEdit ? "save" : "add"%>"> <fieldset> <legend><%=isEdit ? "修改人员资料" : "新建人员资料"%></legend> <table align="center"> <tr> <td>ID:</td> <td><input type="text" name="id" value="<%=isEdit ? id : ""%>" /> </td> </tr> <tr> <td>姓名:</td> <td><input type="text" name="name" value="<%=isEdit ? name : ""%>" /> </td> </tr> <tr> <td>英文名:</td> <td><input type="text" name="englishname" value="<%=isEdit ? englishname : ""%>" /> </td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="sex" value="男" id="sex_male" <%=isEdit && "男".equals(sex) ? "checked" : ""%> /><label for="sex_male">男</label> <input type="radio" name="sex" value="女" id="sex_female" <%=isEdit && "女".equals(sex) ? "checked" : ""%> /><label for="sex_female">女</label></td> </tr> <tr> <td>年龄:</td> <td><input type="text" name="age" value="<%=isEdit ? age : ""%>" /> </td> </tr> <tr> <td>出生日期:</td> <td><input type="text" name="birthday" onfocus="setday(birthday)" value="<%=isEdit ? birthday : ""%>" /> <img alt="" src="images/calendar.gif" onclick="setday(birthday)"> </td> </tr> <tr> <td>描述:</td> <td><textarea rows="10" cols="30" name="description"><%=isEdit ? description : ""%></textarea> </td> </tr> <tr> <td>创建时间:</td> <td><input type="text" name="createtime" onfocus="setday(createtime)" value="<%=isEdit ? createtime : ""%>" /> <img alt="" src="images/calendar.gif" onclick="setday(createtime)"></td> </tr> <tr> <td></td> <td><input type="submit" value="<%=isEdit ? "保存" : "添加人员信息"%>"> <input type="button" value="返回" onclick="history.go(-1); " /></td> </tr> </table> </fieldset> </form></body></html>