java web学生信息管理系统_第1页
java web学生信息管理系统_第2页
java web学生信息管理系统_第3页
java web学生信息管理系统_第4页
java web学生信息管理系统_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Web程序设计 学生信息管理系统 姓名:鲁超、刘千飞、肖伟超万联播、张明明、白浩班级: 软件0901 时间:2011/12/22 一、实验目的 熟练运用web开发技术设计完成一个学生信息管理系统。二、实验原理功能要求:基于B/S架构实现学生信息的增删改查展示功能,实现完整的应用构建和界面设计。技术要求:基于mysql或mssqlserver数据库,以Tomcat为应用效劳器,可使用Jsp+Servelt+Javabean完成,鼓励使用struts,Hibernate框架完成设计。三、实验分组成员姓名成员学号负责内容鲁超202107040101删除模块刘千飞202107040102登陆页面及参与

2、总体内容设计肖伟超202107040103修改模块万联播202107040104查询模块张明明202107040105分页及参与总体内容的设计白浩202107040107增加模块四、实验内容登陆主页源代码:login.html:<!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" con

3、tent="text/html; charset=gb2312"><title>登陆模块</title></head><body bgcolor=lightblue bgcolor="FFFFFF"><h1 align="center"><b>欢送登陆学生信息管理系统</b></h1><hr><form action="forward.jsp" method="post">

4、;<p></p><table width="52%" border="2" align="center"><tr bgcolor="#FFFFCC"><td align="center" width="43%"><div align="center">用户名:</div></td><td width="57%"><div a

5、lign="left"><input type="text" name="username"></div></td></tr><tr bgcolor="#CCFF99"><td align="center" width="43%"><div align="center">密码:</div></td><td width="57&q

6、uot;><div align="left"><input type="password" name="password"></div></td></tr></table><p align="center"><input type="reset" name="Reset" value="重置"><input type="submit&quo

7、t; name="Submit2" value="提交"></p></form></body></html>forward.jsp:<% page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/

8、EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>login forward</title></head><body bgcolor=lightblue><%String username=null;String password=null;re

9、quest.setCharacterEncoding("gb2312");response.setContentType("text/html;charset=gb2312");username=request.getParameter("username");password=request.getParameter("password");if(!username.equals("")&&!password.equals("")%><jsp:f

10、orward page="login_ok.jsp"><jsp:param name="username" value='<%=username%>'/><jsp:param name="username" value='<%=password%>'/></jsp:forward><%else%><jsp:forward page="error.jsp"><jsp:param name=&

11、quot;username" value='<%=username%>'/><jsp:param name="username" value='<%=password%>'/></jsp:forward><%></body></html>l:<% page language="java" contentType="text/html; charset=gb2312" pageEncoding=&qu

12、ot;gb2312"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>Insert title here</title><

13、style type="text/css">inputcolor:red;font-size:12pt;</style></head><body bgcolor=lightblue><center><h1>欢送您使用学生管理系统</h1></center><hr><%String username=null;String password=null;request.setCharacterEncoding("gb2312");response.se

14、tContentType("text/html;charset=gb2312");username=request.getParameter("username");password=request.getParameter("password");out.println("登陆成功,用户名<font color='red'>"+username+"</font>,");out.println("密码<font color='red

15、'>"+password+"</font>");%><br><p align="center">请选择您要进行的操作:<form action="p_cha.html" method="post"><input type="submit" name="cha" value="查 询"> </form><form action="p_shan

16、.html" method="post"><input type="submit" name="shan" value="删 除"> </form><form action="p_gai.html" method="post"><input type="submit" name="gai" value="修 改"> </form><fo

17、rm action="p_zeng.html" method="post"><input type="submit" name="zeng" value="增 加"> </form></body></html>error.jsp:<% page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb

18、2312"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>Error</title></head><body

19、 bgcolor=lightblue><center><h1>欢送您使用学生管理系统</h1></center><%String username=null;String password=null;request.setCharacterEncoding("gb2312");response.setContentType("text/html;charset=gb2312");username=request.getParameter("username");passwor

20、d=request.getParameter("password");out.println("您输入的用户名<font color='red'>"+username+"</font>,");out.println("和密码<font color='red'>"+password+"</font>有一项为空,请重新输入:");%><a href="login.html">-返回重

21、新登陆-</a></body></html>学生信息增加模块:p_zeng.html:<% page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"&g

22、t;<html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>Insert title here</title><style type="text/css">inputcolor:red;font-size:12pt;</style></head><body bgcolor=lightblue><center>

23、<h1>欢送您使用学生管理系统</h1></center><hr><%String username=null;String password=null;request.setCharacterEncoding("gb2312");response.setContentType("text/html;charset=gb2312");username=request.getParameter("username");password=request.getParameter(&qu

24、ot;password");out.println("登陆成功,用户名<font color='red'>"+username+"</font>,");out.println("密码<font color='red'>"+password+"</font>");%><br><p align="center">请选择您要进行的操作:<form action="p_

25、cha.html" method="post"><input type="submit" name="cha" value="查 询"> </form><form action="p_shan.html" method="post"><input type="submit" name="shan" value="删 除"> </form>&l

26、t;form action="p_gai.html" method="post"><input type="submit" name="gai" value="修 改"> </form><form action="p_zeng.html" method="post"><input type="submit" name="zeng" value="增 加&quo

27、t;> </form></body></html>zeng.jsp:<% page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312" import="java.sql.*"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR

28、/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>call stored procedure</title></head><body bgcolor=lightblue> <% int PAGESIZE=3; int pageCount=0; int curPage=1; java.sql.Conne

29、ction conn=null; PreparedStatement pstmt=null; Statement stmt=null; ResultSet rs=null; String cloStr="sno","sname","cclass","sex","age","nation","clname","place" String showStr="学生编号","学生姓名","所在年

30、级","性别","年龄","民族","专业","住址"String sno,sname,cclass,sex,age,nation,clname,place; String strURL="jdbc:mysql:/localhost/test" String strDBUser="root" String strDBPwd="123" try Class.forName("com.mysql.jdbc.Driver&

31、quot;); conn=java.sql.DriverManager.getConnection(strURL,strDBUser,strDBPwd); catch(ClassNotFoundException e) e.printStackTrace(); out.println("您输入的信息有误,请查证后再重新输入!"); catch(Exception ex) ex.printStackTrace(); out.println("您输入的信息有误,请查证后再重新输入!"); try sno=request.getParameter("

32、sno"); byte no=sno.getBytes("ISO-8859-1"); sno=new String(no); sname=request.getParameter("sname"); byte name=sname.getBytes("ISO-8859-1"); sname=new String(name,"gb2312"); cclass=request.getParameter("cclass"); byte clss=cclass.getBytes("I

33、SO-8859-1"); cclass=new String(clss,"gb2312"); sex=request.getParameter("sex"); byte ex=sex.getBytes("ISO-8859-1"); sex=new String(ex,"gb2312"); age=request.getParameter("age"); byte ge=age.getBytes("ISO-8859-1"); age=new String(ge); n

34、ation=request.getParameter("nation"); byte tion=nation.getBytes("ISO-8859-1"); nation=new String(tion,"gb2312"); clname=request.getParameter("clname"); byte cname=clname.getBytes("ISO-8859-1"); clname=new String(cname,"gb2312"); place=reque

35、st.getParameter("place"); byte lace=place.getBytes("ISO-8859-1"); place=new String(lace,"gb2312"); String sqlll="insert into S(sno,sname,cclass,sex,age,nation,clname,place) values('"+sno+"','"+sname+"','"+cclass+"&#

36、39;,'"+sex+"','"+age+"','"+nation+"','"+clname+"','"+place+"')"pstmt=conn.prepareStatement(sqlll);int count3=pstmt.executeUpdate();/插入 String sqllll="select * from S" stmt=conn.createStatement(Re

37、sultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery(sqllll); rs.last();int size=rs.getRow();pageCount=(size%PAGESIZE=0)?(size/PAGESIZE):(size/PAGESIZE+1); catch(Exception ex) ex.printStackTrace(); out.println("您输入的信息有误,请查证后再重新输入!"); /获取想要显示的页数: String integer=reques

38、t.getParameter("curPage"); if(integer=null) integer="1" try curPage=Integer.parseInt(integer); catch(NumberFormatException e) curPage=1; if(curPage<=1) curPage=1; if(curPage>=pageCount) curPage=pageCount; /如果要显示第curPage页,那么游标应移到posion的值是: int posion=(curPage-1)*PAGESIZE+1;

39、rs.absolute(posion); / 设置游标的位置%><br><table border=1 cellspacing=0 width='100%' class=listFram id="maintable"><tr><%for(int i=0;i<showStr.length;i+)out.println("<td height=5>");out.println("<div align='center'>"+show

40、Stri+"</div></td>");%></tr><%int count=0;do if(count>=PAGESIZE)break; out.println("<tr>");for(int i=0;i<cloStr.length;i+)out.println("<td height=5>");out.println("<div align='center'>"+rs.getString(cloStr

41、i)+"</div></td>");out.println("</tr>");count+;while(rs.next();%></table><a href = "cha.jsp?curPage=1" >首页</a> <a href = "cha.jsp?curPage=<%=curPage-1%>" >上一页</a> <a href = "cha.jsp?curPage=<%=

42、curPage+1%>" >下一页</a> <a href = "cha.jsp?curPage=<%=pageCount%>" >尾页</a> 第<%=curPage%>页/共<%=pageCount%>页 <FORM action="" method=get >输入页码数<Input Type=text name=curPage size=4> <Input Type=submit name=g value="跳转&q

43、uot;> </FORM> </body></html>学生信息删除模块:p_shan.html:<!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"&g

44、t;<title>Insert title here</title><style type="text/css">h3color:red;</style></head><body bgcolor=lightblue><center><h1>欢送您使用学生管理系统</h1></center><p align="center"><hr><div align="right"><a

45、href="login_ok.jsp">返回首页</a></div><h3>删 除 操 作</h3><table align="center"><tr><td>请输入学生学号:<form target="mainFrame" action="shan_xuehao.jsp" method="post" ><input type="text" name="sno

46、" size=20><input type="submit" name="su" value="按学号删除"></form></td><td>请输入学生姓名:<form target="mainFrame" action="shan_xingming.jsp" method="post" ><input type="text" name="sname" s

47、ize=20><input type="submit" name="su" value="按姓名删除"></form></td></tr><tr><td>请输入学生性别:<form target="mainFrame" action="shan_xingbie.jsp" method="post" ><input type="text" name="s

48、ex" size=20><input type="submit" name="su" value="按性别删除"></form></td><td>请输入学生住址:<form target="mainFrame" action="shan_dizhi.jsp" method="post" ><input type="text" name="place" si

49、ze=20><input type="submit" name="su" value="按地址删除"></form></td></tr></table><p align="center"><iframe width=700 height=700 name="mainFrame" frameborder="no"></iframe></body></html&

50、gt;按学号删除: Shan_xuehao.jsp:<% page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312" import="java.sql.*"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><

51、;html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>call stored procedure</title></head><body bgcolor=lightblue> <% int PAGESIZE=3; int pageCount=0; int curPage=1; java.sql.Connection conn=null; PreparedStat

52、ement pstmt=null; Statement stmt=null; ResultSet rs=null; String cloStr="sno","sname","cclass","sex","age","nation","clname","place" String showStr="学生编号","学生姓名","所在年级","性别","

53、年龄","民族","专业","住址" String sno; if(conn=null) String strURL="jdbc:mysql:/localhost/test" String strDBUser="root" String strDBPwd="123" try Class.forName("com.mysql.jdbc.Driver"); out.println("连接数据库成功."); conn=java.sq

54、l.DriverManager.getConnection(strURL,strDBUser,strDBPwd); catch(ClassNotFoundException e) e.printStackTrace(); out.println("ClassNotFoundException111"); catch(Exception ex) ex.printStackTrace(); out.println("Exception11"); trysno=request.getParameter("sno"); byte no=sno

55、.getBytes("ISO-8859-1"); sno=new String(no);String sql="delete from S where sno="+sno;pstmt=conn.prepareStatement(sql);int count=pstmt.executeUpdate();/删除String sqllll="select * from S"stmt=conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);rs=

56、stmt.executeQuery(sqllll);rs.last();int size=rs.getRow();pageCount=(size%PAGESIZE=0)?(size/PAGESIZE):(size/PAGESIZE+1);catch(Exception ex) ex.printStackTrace(); out.println("您输入的信息有误,请查证后再重新输入!"); /获取想要显示的页数: String integer=request.getParameter("curPage"); if(integer=null) intege

57、r="1" try curPage=Integer.parseInt(integer); catch(NumberFormatException e) curPage=1; if(curPage<=1) curPage=1; if(curPage>=pageCount) curPage=pageCount; /如果要显示第curPage页,那么游标应移到posion的值是: int posion=(curPage-1)*PAGESIZE+1; rs.absolute(posion); / 设置游标的位置%><br><table borde

58、r=1 cellspacing=0 width='100%' class=listFram id="maintable"><tr><%for(int i=0;i<showStr.length;i+)out.println("<td height=5>");out.println("<div align='center'>"+showStri+"</div></td>");%></tr>&l

59、t;%int count=0;do if(count>=PAGESIZE)break; out.println("<tr>");for(int i=0;i<cloStr.length;i+)out.println("<td height=5>");out.println("<div align='center'>"+rs.getString(cloStri)+"</div></td>");out.println("&l

60、t;/tr>");count+;while(rs.next();%></table><a href = "cha.jsp?curPage=1" >首页</a> <a href = "cha.jsp?curPage=<%=curPage-1%>" >上一页</a> <a href = "cha.jsp?curPage=<%=curPage+1%>" >下一页</a> <a href = "ch

61、a.jsp?curPage=<%=pageCount%>" >尾页</a> 第<%=curPage%>页/共<%=pageCount%>页 <FORM action="" method=get >输入页码数<Input Type=text name=curPage size=4> <Input Type=submit name=g value="跳转"> </FORM> </body></html>其中按姓名(shan_

62、xuehao.jsp)、按性别(shan_xingbie.jsp)、按地址(shan_dizhi.jsp)删除根本同上,此处代码省略。学生信息修改模块:p_gai.html:<!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; chars

63、et=gb2312"><title>Insert title here</title><style type="text/css">h3color:red;</style></head><body bgcolor=lightblue><center><h1>欢送您使用学生管理系统</h1></center><p align="center"><hr><div align="righ

64、t"><a href="login_ok.jsp">返回首页</a></div><h3>修 改 操 作</h3>请输入要修改的学生学号:<form action= method="post" target="mainFrame"><input type="text" name="number" size=20><input type="submit" name="

65、;su" value="查询"> </form><table align="center" width=430><tr><td>请输入新的学生信息:<form target="mainFrame" action="gai.jsp" method="post" >学号:<input type="text" name="sno" size=20>姓名:<input t

66、ype="text" name="sname" size=20>年级:<input type="text" name="cclass" size=20>性别:<input type="text" name="sex" size=20>年龄:<input type="text" name="age" size=20>名族:<input type="text" name=&

67、quot;nation" size=20>专业:<input type="text" name="clname" size=20>地址:<input type="text" name="place" size=20><p align="center"> <input type="submit" name="gai" value="提交"></form></

68、td></tr></table><p align="center"><iframe width=700 height=700 name="mainFrame" frameborder="no"></iframe></body></html>gai.jsp:<% page language="java" contentType="text/html; charset=gb2312" pageEncodi

69、ng="gb2312" import="java.sql.*"%><!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" " :/ /TR/html4/loose.dtd"><html><head><meta -equiv="Content-Type" content="text/html; charset=gb2312"><title>

70、;call stored procedure</title></head><body bgcolor=lightblue> <% java.sql.Connection conn=null; PreparedStatement pstmt=null; Statement stmt=null; ResultSet rs=null; String cloStr="sno","sname","cclass","sex","age","nation&q

71、uot;,"clname","place" String showStr="学生编号","学生姓名","所在年级","性别","年龄","民族","专业","住址"String sno,sname,cclass,sex,age,nation,clname,place; String strURL="jdbc:mysql:/localhost/test" String strDBUser="root" String strDBPwd="123" try Class.forName("com.mysql.jdbc.Driver"); conn=java.sql.DriverManager.getConnection(strURL,strDBUser,strDBPwd); catch(ClassNotFoundException e) e.printStackTrace(); out.println("您输入的信息有误,请查证后再重新

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论