日报

Index.jsp

<%@ page language="java" import="java.sql.*" pageEncoding="utf-8"%>

<%@ page errorPage="error.jsp"%>

<html>

<head>

 <title>学生信息管理系统</title>

 <link rel="stylesheet" type="text/css" href="css/style.css">

</head>

<body>

<h1 style="width: 100%; font-family: 微软雅黑; color:#fff;">学生信息管理系统</h1>

<a href="add.jsp">添加学生信息</a>

<br />

<br />

<table style="width: 50%;">

 <tr>

   <th>学号</th>

   <th>姓名</th>

   <th>性别</th>

   <th>生日</th>

   <th>管理</th>

 </tr>

 <%

   try {

     Class.forName("com.mysql.jdbc.Driver");

     Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8", "root", "123456");

     //使用Statement对象

     Statement stmt = con.createStatement();

     ResultSet rs = stmt.executeQuery("select * from student");

     while (rs.next()) {

       int id = rs.getInt(1);

       out.println("<tr><td>" + rs.getString(1) +"</td><td>" + rs.getString(2) + "</td><td>" + rs.getString(3) + "</td><td>"

               + rs.getString(4) + "</td><td>"+ rs.getString(5) +"</td><td><a href='edit.jsp?id=" + id

               + "'>修改</a>&nbsp;<a href='del.jsp?id=" + id + "'>删除</a></td></tr>");

     }

     rs.close();

     stmt.close();

     con.close();

   } catch (Exception e) {

     out.println("Exception:" + e.getMessage());

   }

 %>

 

</table>

<br />

<hr />

<div style="text-align: center; width: 100%; font-size: 12px; color: #333;">

 &copy;版权所有:石家庄铁道大学信息科学与技术学院&nbsp;&nbsp;<a href="Lab03.png" target="_blank">网站地图</a>

</div>

</body>

</html>

 

 

 

@charset "utf-8";

body{

   background-image: url("stdu.png");

   background-size: cover;

   text-align: center;

}

table {

   width: 400px;

   border: 1px solid #696969;

   border-collapse: collapse;

   margin:0 auto;

}

 

th {

   border: 1px solid #696969;

   background-color: #5f80c9;

}

td {

   text-align: center;

   border: 1px solid ;

   height: 50px;

   opacity:0.8;

   background-color: #fff;

}

input {

   font-size: 20px;

}

a {

   color: #11F7F7;

   text-decoration: none;

   font-size: 18px;

}

 

a:hover {

   color: #F79011;

   text-decoration: underline;

   font-size: 18px;

}

Add.jsp

<%@ page contentType="text/html; charset=utf-8" import="java.sql.*" errorPage="error.jsp"%>

<html>

<head>

 <title>添加学生信息</title>

 <link rel="stylesheet" type="text/css" href="css/style.css">

 <script type="text/javascript">

   function check() {

     var id = document.getElementById("id");

     var name = document.getElementById("name");

     var sex = document.getElementById("sex");

     var birthday= document.getElementById("birthday");

     

     //非空

     if(id.value == '') {

       alert('学号为空');

       name.focus();

       return false;

     }

     if(name.value == '') {

       alert('姓名为空');

       teacher.focus();

       return false;

     }

     if(sex.value == '') {

       alert('性别为空');

       classroom.focus();

       return false;

     }

     if(birthday.value == '') {

       alert('生日为空');

       classroom.focus();

       return false;

     }

   }

 </script type="text/javascript">

</head>

<body>

<%

 Object message = request.getAttribute("message");

 if(message!=null && !"".equals(message)){

 

%>

<script type="text/javascript">

 alert("<%=request.getAttribute("message")%>");

</script>

<%} %>

<form action="addsave.jsp" method="post" onsubmit="return check()">

 <h2>添加学生信息</h2>

 <table style="width: 50%">

   <tr>

     <th width="30%">学号</th>

     <td width="70%"><input name="id" type="text"></td>

   </tr>

   <tr>

     <th>姓名</th>

     <td><input name="name" type="text"></td>

   </tr>

   <tr>

     <th>性别</th>

     <td><input name="sex" type="text"></td>

   </tr>

   <tr>

     <th>生日</th>

     <td><input name="birthday" type="text"></td>

   </tr>

   <tr>

     <td colspan="2"><input type="submit" name="submit" value="添加"> <input type="reset" value="重置"></td>

   </tr>

 </table>

</form>

 

</body>

</html>

posted @   秋渡晚枫  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示