10.30
哈哈!继续选课系统。把选课的两个界面呈上
来,上代码!
<!DOCTYPE html> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>show page</title> <style type="text/css"> body{ background: #d7c7e9; align-items: center; text-align: center; } </style> </head> <body> <h3>选择课程:</h3> <form action="verifyWindow.jsp" method="get"> 课程名称:<input list="classnames" name="classname"> <datalist id="classnames"> <option value="Java语言" > <option value="统一建模语言" > <option value="数据结构与算法" > <option value="杨老师" > <option value="王老师" > </datalist><br> 教师名称:<input list="teachers" name="teacher"> <datalist id="teachers"> <option value="王建民" > <option value="刘立嘉" > <option value="刘丹" > <option value="杨老师" > <option value="王老师" > </datalist><br> 上课地点:<input list="places" name="place"> <datalist id="places"> <option value="基教"> <option value="一教"> <option value="二教"> <option value="三教"> </datalist><br> <input type="submit"value="选课"> </form> </body> </html>
验证信息的界面
<!DOCTYPE html> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="systemUse.*"%> <%@page import="java.util.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head> <meta charset="UTF-8"> <title>verify page</title> </head> <body> <% String username=(String)session.getAttribute("username"); String password=(String)session.getAttribute("password"); %> <% int i=0; boolean flag=true; boolean flag1=true; String s[]={"王建民","刘丹","刘立嘉","杨老师","王老师"}; String s1[]={"基教","一教","二教","三教"}; String name=request.getParameter("classname"); String teacher=request.getParameter("teacher"); String place=request.getParameter("place"); while(i<s.length) { if(!s[i].equals(teacher)) { flag=false; } else { flag=true; break; } i++; }%> <% if(!flag) { request.setAttribute("Error", "老师不对"); %> <jsp:forward page="showWindow.jsp"></jsp:forward> <% } i=0; String s3=place.substring(0,2); while(flag==true&&i<s1.length) { if(!s1[i].equals(s3)) { flag1=false; } else { flag1=true; break; } i++; } if(!flag1) { request.setAttribute("Error", "教室不对"); %> <jsp:forward page="showWindow.jsp"></jsp:forward> <% } /*String userid="20193878"; String userpass="171017";*/ System.out.println(username+" "+password+" "+name+" "+teacher+" " + place); userData A=new userData(name,teacher,place,username,password); inputToMYSQL add=new inputToMYSQL(); /*String temp=name+teacher+place; List<String> str=new ArrayList<String>(); str=add.getData(); if(str.contains(temp)) { request.setAttribute("Error", "录入重复"); %> <jsp:forward page="showWindow.jsp"></jsp:forward> <% }*/ add.addData(A); %> <jsp:forward page="showWindow.jsp"></jsp:forward> </body> </html>
哈哈,,至此,选课系统全部发表完毕。虽然不是很满意,但是还是把功能实现了,继续努力,争取写出更好的系统。