当前位置: 代码迷 >> J2EE >> 帖子太长,占据了3层楼,请各位解决有关问题
  详细解决方案

帖子太长,占据了3层楼,请各位解决有关问题

热度:28   发布时间:2016-04-22 02:19:49.0
帖子太长,占据了3层楼,请各位解决问题
listperson.jsp
JScript code
<%@ 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>
  相关解决方案