2019年12月23日 下午自习成果
一、内容
今天下午主要对上一周的分级考试的代码进行了完善,并且增加了选课,但是也遇到了问题。
二、源代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>首页</title> <style> .a{ font-size: 26px; margin-top: 20px; } </style> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: blue;">老师您好</h1> <div class="a"> <a href="index.jsp">注销</a> </div> <div class="a"> <a href="teacherUpdate.jsp">修改个人信息</a> </div> <div class="a"> <a href="updateServlet?method=classlist">修改课程信息</a> </div> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>遍历</title> <style> .a{ margin-top: 20px; } .b{ font-size: 20px; width: 160px; color: white; background-color: greenyellow; } .tb,td { border: 1px solid black; font-size: 22px; } </style> </head> <body> <% Object message = request.getAttribute("message"); Object grade_list = request.getAttribute("grade_list"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: red;">信息列表</h1> <a href="index.jsp">返回主页</a> <table class="tb"> <tr> <td>课程号</td> <td>课程名称</td> <td>课程容量</td> <td>已选人数</td> <td align="center" colspan="2">操作</td> </tr> <c:forEach items="${class_list}" var="item"> <tr> <td>${item.cnumber}</td> <td>${item.cname}</td> <td>${item.most}</td> <td>${item.have}</td> <td><a href="classChange.jsp?cnumber=${item.cnumber}&cname=${item.cname}&most=${item.most}&have=${item.have}">修改</a></td> <td><a href="deleteServlet?method=class&id=${item.cnumber}">删除</a></td> </tr> </c:forEach> </table> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>增加课程信息</title> <style> .a{ margin-top: 20px; } .b{ font-size: 20px; width: 160px; color: white; background-color: greenyellow; } .c{ margin-top: 20px; color: red; } </style> </head> <body> <div align="center"> <h1 style="color: red;">增加课程信息</h1> <a href="teacher.jsp">返回主页</a> <form action="updateServlet?method=class" method="post" onsubmit="return check()"> <div class="c"> 课程编号<input type="text" id="cnumber" name="cnumber" /> </div> <div class="a"> 课程名称<input type="text" id="cname" name="cname" "/> </div> <div class="a"> 最大容量<input type="text" id="most" name="most" /> </div> <div class="a"> <button type="submit" class="b">修 改</button> </div> </form> </div> <script type="text/javascript"> function check() { var sname = document.getElementById("cnumber"); var ssex= document.getElementById("cname"); var snumber= document.getElementById("most"); //非空 if(cnumber.value == '') { alert('课程编号为空'); cnumber.focus(); return false; } else if(cname.value == '') { alert('课程名称为空'); cname.focus(); return false; } else if(most.value == '') { alert('课程容量为空'); most.focus(); return false; } } </script> </body> </html>