├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── vcs.xml ├── jsLibraryMappings.xml ├── sqldialects.xml ├── encodings.xml ├── modules.xml ├── dataSources.ids ├── dataSources.xml ├── compiler.xml ├── artifacts │ └── Orange_war_exploded.xml └── misc.xml ├── web ├── META-INF │ └── MANIFEST.MF ├── favicon.ico ├── img │ ├── huar.jpg │ ├── lake.jpg │ ├── orange.png │ ├── route.jpg │ ├── stone.jpg │ └── loading.gif ├── admin2 │ ├── sample.csv │ ├── student-sample.csv │ ├── index.jsp │ ├── manage-passwd.jsp │ └── uploadfile.jsp ├── WEB-INF │ ├── lib │ │ ├── jstl.jar │ │ ├── ojdbc6_g.jar │ │ ├── standard.jar │ │ ├── commons-csv-1.2.jar │ │ ├── commons-io-2.4.jar │ │ ├── fastjson-1.2.7.jar │ │ └── commons-fileupload-1.3.1.jar │ ├── content │ │ ├── admin │ │ │ ├── bottom.jsp │ │ │ ├── footer.jsp │ │ │ ├── view-passwd.jsp │ │ │ ├── top.jsp │ │ │ ├── view-dept.jsp │ │ │ └── view-admin2.jsp │ │ ├── admin2 │ │ │ ├── bottom.jsp │ │ │ ├── footer.jsp │ │ │ ├── notice.jsp │ │ │ └── top.jsp │ │ ├── teacher │ │ │ ├── bottom.jsp │ │ │ └── top.jsp │ │ └── user │ │ │ ├── bottom.jsp │ │ │ └── top.jsp │ └── web.xml ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── css │ └── style.css ├── footer.jsp ├── js │ ├── npm.js │ └── user.js ├── admin │ ├── index.jsp │ ├── dept.jsp │ ├── passwd.jsp │ └── admin2.jsp ├── index.jsp ├── header.jsp ├── 404.jsp ├── login.jsp ├── teacher │ ├── passwd.jsp │ ├── score.jsp │ ├── teacher.js │ ├── index.jsp │ ├── courselist.jsp │ └── stulist.jsp ├── error.jsp └── user │ ├── index.jsp │ ├── courselist.jsp │ ├── user.js │ ├── passwd.jsp │ ├── score.jsp │ └── Select.jsp ├── src └── cn │ └── edu │ └── jlu │ └── orange │ ├── config.properties │ ├── servlet │ ├── TestServlet.java │ ├── GetNoticeByIdServlet.java │ ├── admin2 │ │ ├── AddOneTeacherServlet.java │ │ ├── ChangePasswordServlet.java │ │ ├── AddStudentServlet.java │ │ ├── ResetOrDeleteTeacherServlet.java │ │ └── AllStuServlet.java │ ├── user │ │ ├── UserPasswdServlet.java │ │ └── CourseSelectionServlet.java │ ├── teacher │ │ ├── TeacherPasswdServlet.java │ │ └── ScoreServlet.java │ ├── admin │ │ ├── PasswdServlet.java │ │ ├── OpenSystemServlet.java │ │ ├── DeptServlet.java │ │ ├── NoticeServlet.java │ │ └── AdminServlet.java │ ├── IPServlet.java │ └── LoginCheckServlet.java │ └── JDBCUtil.java ├── screenshots ├── 002首页FireShot Capture 8 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png ├── 031学生首页FireShot Capture 36 - 首页 - 学生选课系统 - http___local.dev_8080_user_.png ├── 001FireShot Capture 4 - 登录 - http___local.dev_8080_login.jsp_reason=login.png ├── 003查看公告FireShot Capture 11 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png ├── 004发布公告FireShot Capture 13 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png ├── 011教务首页FireShot Capture 17 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_.png ├── 021教师首页FireShot Capture 28 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_.png ├── 005院系管理FireShot Capture 14 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_dept.jsp.png ├── 032学生选课FireShot Capture 38 - 首页 - 学生选课系统 - http___local.dev_8080_user_select.jsp.png ├── 035学生信息FireShot Capture 41 - 首页 - 学生选课系统 - http___local.dev_8080_user_passwd.jsp.png ├── 036学生信息FireShot Capture 42 - 首页 - 学生选课系统 - http___local.dev_8080_user_passwd.jsp.png ├── 033学生课表FireShot Capture 39 - 首页 - 学生选课系统 - http___local.dev_8080_user_courselist.jsp.png ├── 006教务用户管理FireShot Capture 15 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_admin2.jsp.png ├── 007管理员更改密码FireShot Capture 16 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_passwd.jsp.png ├── 024教师上成绩FireShot Capture 34 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_score.jsp.png ├── 025教师信息FireShot Capture 35 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_passwd.jsp.png ├── 022教师课表FireShot Capture 32 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_courselist.jsp.png ├── 012教师一览FireShot Capture 18 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-teacher.jsp.png ├── 014学生管理FireShot Capture 22 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-student.jsp.png ├── 015课程管理FireShot Capture 23 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png ├── 016课程管理2FireShot Capture 24 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png ├── 019教务密码FireShot Capture 27 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-passwd.jsp.png ├── 013批量添加教师FireShot Capture 20 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-teacher.jsp.png ├── 017课程管理3添加教室FireShot Capture 25 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png ├── 018课程管理4添加时段FireShot Capture 26 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png ├── 023教师查询学生名单FireShot Capture 33 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_stulist.jsp_sec=540002.png └── 034学生查成绩FireShot Capture 40 - 首页 - 学生选课系统 - http___local.dev_8080_user_score.jsp_semester=2015-2016-2.png └── Orange.iml /.idea/.name: -------------------------------------------------------------------------------- 1 | Orange -------------------------------------------------------------------------------- /web/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/favicon.ico -------------------------------------------------------------------------------- /web/img/huar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/img/huar.jpg -------------------------------------------------------------------------------- /web/img/lake.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/img/lake.jpg -------------------------------------------------------------------------------- /web/img/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/img/orange.png -------------------------------------------------------------------------------- /web/img/route.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/img/route.jpg -------------------------------------------------------------------------------- /web/img/stone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/img/stone.jpg -------------------------------------------------------------------------------- /web/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/img/loading.gif -------------------------------------------------------------------------------- /web/admin2/sample.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/admin2/sample.csv -------------------------------------------------------------------------------- /web/WEB-INF/lib/jstl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/jstl.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/ojdbc6_g.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/ojdbc6_g.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/standard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/standard.jar -------------------------------------------------------------------------------- /web/admin2/student-sample.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/admin2/student-sample.csv -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-csv-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/commons-csv-1.2.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/fastjson-1.2.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/fastjson-1.2.7.jar -------------------------------------------------------------------------------- /web/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /web/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /web/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /web/WEB-INF/lib/commons-fileupload-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/WEB-INF/lib/commons-fileupload-1.3.1.jar -------------------------------------------------------------------------------- /web/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/web/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/config.properties: -------------------------------------------------------------------------------- 1 | driver=oracle.jdbc.driver.OracleDriver 2 | url=jdbc:oracle:thin:@127.0.0.1:1521:orcl 3 | user=ouser 4 | pass=Ozszs233 -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /screenshots/002首页FireShot Capture 8 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/002首页FireShot Capture 8 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png -------------------------------------------------------------------------------- /screenshots/031学生首页FireShot Capture 36 - 首页 - 学生选课系统 - http___local.dev_8080_user_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/031学生首页FireShot Capture 36 - 首页 - 学生选课系统 - http___local.dev_8080_user_.png -------------------------------------------------------------------------------- /screenshots/001FireShot Capture 4 - 登录 - http___local.dev_8080_login.jsp_reason=login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/001FireShot Capture 4 - 登录 - http___local.dev_8080_login.jsp_reason=login.png -------------------------------------------------------------------------------- /screenshots/003查看公告FireShot Capture 11 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/003查看公告FireShot Capture 11 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png -------------------------------------------------------------------------------- /screenshots/004发布公告FireShot Capture 13 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/004发布公告FireShot Capture 13 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_.png -------------------------------------------------------------------------------- /screenshots/011教务首页FireShot Capture 17 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/011教务首页FireShot Capture 17 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_.png -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/sqldialects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /screenshots/021教师首页FireShot Capture 28 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/021教师首页FireShot Capture 28 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /screenshots/005院系管理FireShot Capture 14 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_dept.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/005院系管理FireShot Capture 14 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_dept.jsp.png -------------------------------------------------------------------------------- /screenshots/032学生选课FireShot Capture 38 - 首页 - 学生选课系统 - http___local.dev_8080_user_select.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/032学生选课FireShot Capture 38 - 首页 - 学生选课系统 - http___local.dev_8080_user_select.jsp.png -------------------------------------------------------------------------------- /screenshots/035学生信息FireShot Capture 41 - 首页 - 学生选课系统 - http___local.dev_8080_user_passwd.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/035学生信息FireShot Capture 41 - 首页 - 学生选课系统 - http___local.dev_8080_user_passwd.jsp.png -------------------------------------------------------------------------------- /screenshots/036学生信息FireShot Capture 42 - 首页 - 学生选课系统 - http___local.dev_8080_user_passwd.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/036学生信息FireShot Capture 42 - 首页 - 学生选课系统 - http___local.dev_8080_user_passwd.jsp.png -------------------------------------------------------------------------------- /screenshots/033学生课表FireShot Capture 39 - 首页 - 学生选课系统 - http___local.dev_8080_user_courselist.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/033学生课表FireShot Capture 39 - 首页 - 学生选课系统 - http___local.dev_8080_user_courselist.jsp.png -------------------------------------------------------------------------------- /screenshots/006教务用户管理FireShot Capture 15 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_admin2.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/006教务用户管理FireShot Capture 15 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_admin2.jsp.png -------------------------------------------------------------------------------- /screenshots/007管理员更改密码FireShot Capture 16 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_passwd.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/007管理员更改密码FireShot Capture 16 - 超级管理员 - 学生选课系统 - http___local.dev_8080_admin_passwd.jsp.png -------------------------------------------------------------------------------- /screenshots/024教师上成绩FireShot Capture 34 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_score.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/024教师上成绩FireShot Capture 34 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_score.jsp.png -------------------------------------------------------------------------------- /screenshots/025教师信息FireShot Capture 35 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_passwd.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/025教师信息FireShot Capture 35 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_passwd.jsp.png -------------------------------------------------------------------------------- /screenshots/022教师课表FireShot Capture 32 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_courselist.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/022教师课表FireShot Capture 32 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_courselist.jsp.png -------------------------------------------------------------------------------- /screenshots/012教师一览FireShot Capture 18 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-teacher.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/012教师一览FireShot Capture 18 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-teacher.jsp.png -------------------------------------------------------------------------------- /screenshots/014学生管理FireShot Capture 22 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-student.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/014学生管理FireShot Capture 22 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-student.jsp.png -------------------------------------------------------------------------------- /screenshots/015课程管理FireShot Capture 23 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/015课程管理FireShot Capture 23 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png -------------------------------------------------------------------------------- /screenshots/016课程管理2FireShot Capture 24 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/016课程管理2FireShot Capture 24 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png -------------------------------------------------------------------------------- /screenshots/019教务密码FireShot Capture 27 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-passwd.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/019教务密码FireShot Capture 27 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-passwd.jsp.png -------------------------------------------------------------------------------- /screenshots/013批量添加教师FireShot Capture 20 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-teacher.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/013批量添加教师FireShot Capture 20 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-teacher.jsp.png -------------------------------------------------------------------------------- /screenshots/017课程管理3添加教室FireShot Capture 25 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/017课程管理3添加教室FireShot Capture 25 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png -------------------------------------------------------------------------------- /screenshots/018课程管理4添加时段FireShot Capture 26 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/018课程管理4添加时段FireShot Capture 26 - 教务管理 - 学生选课系统 - http___local.dev_8080_admin2_manage-course.jsp.png -------------------------------------------------------------------------------- /screenshots/023教师查询学生名单FireShot Capture 33 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_stulist.jsp_sec=540002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/023教师查询学生名单FireShot Capture 33 - 教师首页 - 学生选课系统 - http___local.dev_8080_teacher_stulist.jsp_sec=540002.png -------------------------------------------------------------------------------- /screenshots/034学生查成绩FireShot Capture 40 - 首页 - 学生选课系统 - http___local.dev_8080_user_score.jsp_semester=2015-2016-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Orangejlu/Orange/HEAD/screenshots/034学生查成绩FireShot Capture 40 - 首页 - 学生选课系统 - http___local.dev_8080_user_score.jsp_semester=2015-2016-2.png -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/dataSources.ids: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin/bottom.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-01-11-011 5 | Time: 15:56 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 |
12 | 13 | <%@ include file="footer.jsp"%> -------------------------------------------------------------------------------- /web/WEB-INF/content/admin2/bottom.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-19-019 5 | Time: 23:05 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | 12 |
13 | 14 | <%@ include file="footer.jsp" %> 15 | -------------------------------------------------------------------------------- /web/css/style.css: -------------------------------------------------------------------------------- 1 | /*wrap,footer*/ 2 | *{ 3 | margin: 0; 4 | padding: 0; 5 | } 6 | html, body{ 7 | height: 100%; 8 | } 9 | .wrap{ 10 | min-height: 100%; 11 | height: auto !important; 12 | height: 100%; 13 | margin: 0 auto -90px; 14 | } 15 | .end{ 16 | clear:both; 17 | height: 70px; 18 | } 19 | #copyright { 20 | background-color: gray; 21 | text-align: center; 22 | height: 70px; 23 | padding-top: 20px; 24 | } -------------------------------------------------------------------------------- /web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 404 8 | /404.jsp 9 | 10 | -------------------------------------------------------------------------------- /web/footer.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-08-008 5 | Time: 11:38 上午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | oracle 6 | false 7 | oracle.jdbc.OracleDriver 8 | jdbc:oracle:thin:@//localhost:1521/orcl 9 | 10 | 11 | -------------------------------------------------------------------------------- /web/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /web/admin/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-15-015 5 | Time: 19:24 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | <%@ include file="../WEB-INF/content/admin/top.jsp"%> 12 | 13 | <%@ include file="../WEB-INF/content/admin/view-home.jsp"%> 14 | 15 | <%@ include file="../WEB-INF/content/admin/bottom.jsp"%> -------------------------------------------------------------------------------- /web/admin/dept.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-01-11-011 5 | Time: 18:53 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | <%@ include file="../WEB-INF/content/admin/top.jsp"%> 12 | 13 | <%@ include file="../WEB-INF/content/admin/view-dept.jsp"%> 14 | 15 | <%@ include file="../WEB-INF/content/admin/bottom.jsp"%> 16 | -------------------------------------------------------------------------------- /web/admin/passwd.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-01-11-011 5 | Time: 22:02 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | <%@ include file="../WEB-INF/content/admin/top.jsp"%> 11 | 12 | <%@ include file="../WEB-INF/content/admin/view-passwd.jsp"%> 13 | 14 | 15 | <%@ include file="../WEB-INF/content/admin/bottom.jsp"%> 16 | -------------------------------------------------------------------------------- /web/admin/admin2.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-01-11-011 5 | Time: 19:45 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | 9 | <%@ page trimDirectiveWhitespaces="true" %> 10 | <%@ page pageEncoding="UTF-8" language="java" %> 11 | 12 | <%@ include file="../WEB-INF/content/admin/top.jsp"%> 13 | 14 | <%@ include file="../WEB-INF/content/admin/view-admin2.jsp"%> 15 | 16 | <%@ include file="../WEB-INF/content/admin/bottom.jsp"%> 17 | 18 | -------------------------------------------------------------------------------- /web/admin2/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-17-017 5 | Time: 12:50 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | <%@ include file="../WEB-INF/content/admin2/top.jsp" %> 12 | <%--页面上半部分,container开始--%> 13 | 16 | <%@ include file="../WEB-INF/content/admin2/notice.jsp" %> 17 | <%--结束container,页面下半部分--%> 18 | <%@ include file="../WEB-INF/content/admin2/bottom.jsp" %> -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin2/footer.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-19-019 5 | Time: 19:28 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | 9 | <%@ page trimDirectiveWhitespaces="true" %> 10 | <%@ page pageEncoding="UTF-8" language="java" %> 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin/footer.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-18-018 5 | Time: 13:34 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /web/WEB-INF/content/teacher/bottom.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-02-15-015 5 | Time: 09:08 上午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | 12 |
13 | 14 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/TestServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | import java.io.PrintWriter; 10 | 11 | /** 12 | * Created by lin on 2015-12-18-018. 13 | */ 14 | @WebServlet(name = "TestServlet",value = "*.do") 15 | public class TestServlet extends HttpServlet { 16 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 17 | PrintWriter out = response.getWriter(); 18 | out.write("Hello"); 19 | } 20 | 21 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 22 | PrintWriter out = response.getWriter(); 23 | out.write("Hello"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /web/WEB-INF/content/user/bottom.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-02-15-015 5 | Time: 09:08 上午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 |
11 | 12 |
13 | 14 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /web/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.*" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: lin 5 | Date: 2015-12-04-004 6 | Time: 13:47 下午 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page trimDirectiveWhitespaces="true" %> 10 | <%@ page pageEncoding="UTF-8" language="java" %> 11 | 12 | <%@ include file="header.jsp" %> 13 | 学生选课系统 14 | 15 | 16 | <% 17 | if(logined != null){ 18 | if (session.getAttribute("type")!=null) 19 | switch ((Integer)session.getAttribute("type")){ 20 | case 0:response.sendRedirect("admin/");break; 21 | case 1:response.sendRedirect("admin2/");break; 22 | case 2:response.sendRedirect("teacher/");break; 23 | case 3:response.sendRedirect("user/");break; 24 | default:response.sendRedirect("login.jsp?reason=login"); 25 | } 26 | else{ 27 | response.sendRedirect("login.jsp?reason=login"); 28 | } 29 | } 30 | %> 31 | <%@include file="footer.jsp" %> -------------------------------------------------------------------------------- /.idea/artifacts/Orange_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/Orange_war_exploded 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin/view-passwd.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-18-018 5 | Time: 17:57 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 |

更改密码

11 | 12 | 13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 |
24 | "> 25 | 26 |

更改成功后需要重新登陆。

27 |

 

28 |
29 | -------------------------------------------------------------------------------- /Orange.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/GetNoticeByIdServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import java.io.IOException; 11 | 12 | /** 13 | * Created by lin on 2015-12-19-019. 14 | */ 15 | @WebServlet(name = "GetNoticeByIdServlet",value = "/getnoticecontent.do") 16 | public class GetNoticeByIdServlet extends HttpServlet { 17 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 18 | 19 | 20 | } 21 | 22 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | request.setCharacterEncoding("UTF-8"); 24 | response.setCharacterEncoding("UTF-8"); 25 | String logined = (String) request.getSession().getAttribute("logined"); 26 | Integer type = (Integer) request.getSession().getAttribute("type"); 27 | if (logined == null || type == null) { 28 | return; 29 | } 30 | String id = request.getParameter("noticeid"); 31 | if (id==null)return; 32 | //System.out.println("参数为"+id); 33 | String content = JDBCUtil.getNoticeById(id); 34 | content = content.replace("\n","
"); 35 | if (!content.substring(content.indexOf("")) 36 | .contains(type.toString()) 37 | && !type.toString().trim().equals("0")) { 38 | return; 39 | } 40 | response.getWriter().print(content); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Android 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /web/header.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-09-009 5 | Time: 22:05 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ page trimDirectiveWhitespaces="true" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 13 | // System.out.println("URI:"+request.getRequestURL()); 14 | // System.out.println(basePath); 15 | String reason = request.getParameter("reason"); 16 | if (reason != null && reason.equals("logout")) { 17 | session.setAttribute("logined", null); 18 | out.println("logout"); 19 | response.sendRedirect(basePath+"login.jsp?reason=haslogout"); 20 | return; 21 | } 22 | String logined = (String) session.getAttribute("logined"); 23 | if (logined == null && request.getParameter("reason") == null) { 24 | response.sendRedirect(basePath+"login.jsp?reason=login"); 25 | return; 26 | } 27 | Integer type = (Integer) session.getAttribute("type"); 28 | if (type == null) type = -1; 29 | %> 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | <%----%> 41 | 49 | 50 | -------------------------------------------------------------------------------- /web/404.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-17-017 5 | Time: 15:20 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 11 | 12 | 13 | 14 | 15 | 16 | 17 | <% 18 | String path = request.getContextPath(); 19 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 20 | %> 21 | "> 22 | 23 | 24 | <%----%> 25 | 26 | 27 | 34 | 404 - 学生选课系统 35 | 36 | 37 |
38 |
39 |
40 |

404 Not Found

41 |
42 |
43 |

很抱歉,您请求的资源当前不可用,请检查网址

44 |

返回首页

45 |
46 |
47 | 48 |
49 |
50 |
51 | <%@ include file="footer.jsp" %> 52 | -------------------------------------------------------------------------------- /web/admin2/manage-passwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %><%-- 5 | Created by IntelliJ IDEA. 6 | User: lin 7 | Date: 2015-12-19-019 8 | Time: 23:07 下午 9 | To change this template use File | Settings | File Templates. 10 | --%> 11 | <%@ page trimDirectiveWhitespaces="true" %> 12 | <%@ page pageEncoding="UTF-8" language="java" %> 13 | 14 | <%@ include file="../WEB-INF/content/admin2/top.jsp" %> 15 | <%--页面上半部分,container开始--%> 16 | 19 | 22 |

我的信息

23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 38 | 39 |
角色教务管理员
用户名<%=session.getAttribute("logined")%> 32 |
所属院系<%=session.getAttribute("dept")%> 37 |
40 |
41 |
42 |

修改登录密码

43 |
 
44 |
45 | 46 | 47 | 48 |
49 |
50 | 51 | 52 | 53 |
54 | "> 55 | 56 |

请注意,管理员有权重置您的密码(但看不到您的密码)。更改成功后需要重新登陆。

57 |
58 | <%--结束container,页面下半部分--%> 59 | <%@ include file="../WEB-INF/content/admin2/bottom.jsp" %> 60 | -------------------------------------------------------------------------------- /web/login.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-09-009 5 | Time: 22:03 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | 11 | <%@ include file="header.jsp" %> 12 | 登录 13 | 35 | 36 | 37 | 38 |
39 | 40 |
41 |
42 |

43 |   44 | 登录 45 |

46 |
47 | 48 | 50 |
51 |
52 | 53 | 54 | 55 |
56 |
 
57 | 58 |
59 | 67 |
68 | 69 |
70 | 71 | <%@include file="footer.jsp" %> 72 | -------------------------------------------------------------------------------- /web/teacher/passwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %> 5 | <%@ page import="java.sql.ResultSet" %><%-- 6 | Created by IntelliJ IDEA. 7 | User: lin 8 | Date: 2016-02-22-022 9 | Time: 14:35 下午 10 | To change this template use File | Settings | File Templates. 11 | --%> 12 | <%@ page trimDirectiveWhitespaces="true" %> 13 | <%@ page pageEncoding="UTF-8" language="java" %> 14 | <%@ include file="../WEB-INF/content/teacher/top.jsp" %> 15 | 18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 |
30 | "> 31 | 32 |
33 |

注意:管理员可以重置您的密码()但看不到您的密码;修改密码后需要重新登录

34 |
35 |

 

36 |
37 | 38 | <% 39 | Connection con = JDBCUtil.getConnection(); 40 | String sql = "SELECT t_id,t_name,t_level,t_email,d_name FROM teacher WHERE t_id = ?"; 41 | try { 42 | PreparedStatement pstmt = con.prepareStatement(sql); 43 | pstmt.setString(1, (String) session.getAttribute("userId")); 44 | ResultSet rs = pstmt.executeQuery(); 45 | while (rs.next()) { 46 | out.println(""); 47 | out.println(""); 48 | out.println(""); 49 | out.println(""); 50 | out.println(""); 51 | } 52 | } catch (SQLException e) { 53 | } 54 | %> 55 |
编号" + rs.getString("t_id") + "
姓名" + rs.getString("t_name") + "
职称" + rs.getString("t_level") + "
邮箱" + rs.getString("t_email") + "
学院" + rs.getString("d_name") + "
56 |
57 | <%@ include file="../WEB-INF/content/teacher/bottom.jsp" %> 58 | -------------------------------------------------------------------------------- /web/error.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-15-015 5 | Time: 21:11 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" isErrorPage="true" %> 10 | <%--<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>--%> 11 | 12 | 13 | 14 | 15 | 16 | 17 | <% 18 | String path = request.getContextPath(); 19 | String basePath = request.getScheme() + "://" 20 | + request.getServerName() + ":" 21 | + request.getServerPort() + path + "/";%> 22 | <%--">--%> 23 | 24 | 25 | 26 | 27 | 34 | 出错了 35 | 36 | 37 | 38 |
39 |
40 |
41 |

服务器错误

42 |
43 |

很抱歉,服务器出错了,请联系管理员

44 | 45 |

返回首页

46 |
47 |

错误信息

48 | <% if (exception != null) { 49 | out.println("
" + exception.toString() + "
"); 50 | } %> 51 |
52 | <% String referer = request.getHeader("referer"); 53 | if (referer != null) { 54 | out.println("

返回来源页

"); 55 | } 56 | %> 57 |
58 | 59 |
60 |
61 |
62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin2/AddOneTeacherServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin2; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-01-09-009. 19 | */ 20 | @WebServlet(name = "AddOneTeacherServlet",value = "/admin2/addteacher.do") 21 | public class AddOneTeacherServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | response.setContentType("text/html;charset=UTF-8"); 25 | PrintWriter out = response.getWriter(); 26 | //鉴权 27 | String logined = (String) session.getAttribute("logined"); 28 | Integer type = (Integer) session.getAttribute("type"); 29 | if (logined == null || type == null || type != 1) { 30 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 31 | return; 32 | } 33 | 34 | String id = request.getParameter("addid"); 35 | String name = request.getParameter("addname"); 36 | String level = request.getParameter("addlevel"); 37 | String email = request.getParameter("addemail"); 38 | String d_name = (String) request.getSession().getAttribute("d_name"); 39 | 40 | if (id == null || name == null || level == null || email == null || d_name == null) { 41 | out.println("
error
"); 42 | return; 43 | } 44 | //t_id,t_name,t_level,t_email,t_passwd,d_name 45 | String sql = "INSERT INTO teacher values(?,?,?,?,?,?)"; 46 | Connection con = JDBCUtil.getConnection(); 47 | try { 48 | PreparedStatement pstmt = con.prepareStatement(sql); 49 | pstmt.setString(1, id); 50 | pstmt.setString(2, name); 51 | pstmt.setString(3, level); 52 | pstmt.setString(4, email); 53 | pstmt.setString(5, JDBCUtil.MD5("Orange" + id + id)); 54 | pstmt.setString(6, d_name); 55 | int i = pstmt.executeUpdate(); 56 | out.println("
" + i + "行已添加成功
"); 57 | } catch (SQLException e) { 58 | e.printStackTrace(); 59 | out.println("
" + e.getMessage() + "
"); 60 | } 61 | } 62 | 63 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 64 | response.setContentType("text/html;charset=UTF-8"); 65 | response.getWriter().println("
12你好3
"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/user/UserPasswdServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.user; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-02-19-019. 19 | */ 20 | @WebServlet(name = "UserPasswdServlet", value = "/user/passwd.do") 21 | public class UserPasswdServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | //鉴权 25 | String logined = (String) session.getAttribute("logined"); 26 | Integer type = (Integer) session.getAttribute("type"); 27 | response.setContentType("application/json;charset=UTF-8"); 28 | PrintWriter out = response.getWriter(); 29 | if (logined == null || type == null || type != 3) { 30 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 31 | return; 32 | } 33 | String oldpass = request.getParameter("passwd"), 34 | newpass = request.getParameter("new-passwd"), 35 | userid = request.getParameter("user-id"); 36 | if (oldpass == null || newpass == null || userid == null 37 | || oldpass.length() != 32 || newpass.length() != 32) { 38 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 39 | return; 40 | } 41 | Connection con = JDBCUtil.getConnection(); 42 | try { 43 | PreparedStatement pstmt = con.prepareStatement( 44 | "UPDATE student SET s_passwd = ? WHERE s_id = ? AND s_passwd = ?"); 45 | pstmt.setString(1, newpass); 46 | pstmt.setString(2, userid); 47 | pstmt.setString(3, oldpass); 48 | int i = pstmt.executeUpdate(); 49 | if (i > 0) { 50 | session.setAttribute("logined", null); 51 | System.out.println("学生修改密码成功" + i); 52 | out.println("{\"ok\":\"true\",\"msg\":\"修改密码成功\"}"); 53 | } else out.println("{\"ok\":\"false\",\"msg\":\"修改失败,请检查原密码是否正确\"}"); 54 | pstmt.close(); 55 | JDBCUtil.closeConnection(); 56 | } catch (SQLException e) { 57 | e.printStackTrace(); 58 | out.println("{\"ok\":\"false\"," + 59 | "\"msg\":\"数据库错误(" + JDBCUtil.jsonReplace(e.getMessage()) + ")\"}"); 60 | } 61 | } 62 | 63 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/teacher/TeacherPasswdServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.teacher; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-02-22-022. 19 | */ 20 | @WebServlet(name = "TeacherPasswdServlet", value = "/teacher/passwd.do") 21 | public class TeacherPasswdServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | //鉴权 25 | String logined = (String) session.getAttribute("logined"); 26 | Integer type = (Integer) session.getAttribute("type"); 27 | response.setContentType("application/json;charset=UTF-8"); 28 | PrintWriter out = response.getWriter(); 29 | if (logined == null || type == null || type != 2) { 30 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 31 | return; 32 | } 33 | String oldpass = request.getParameter("old-pass"), 34 | newpass = request.getParameter("new-pass"), 35 | userid = request.getParameter("t-id"); 36 | if (oldpass == null || newpass == null || userid == null 37 | || oldpass.length() != 32 || newpass.length() != 32) { 38 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 39 | return; 40 | } 41 | Connection con = JDBCUtil.getConnection(); 42 | String sql = "UPDATE teacher set t_passwd = ? WHERE t_id = ? AND t_passwd = ?"; 43 | try { 44 | PreparedStatement pstmt = con.prepareStatement(sql); 45 | pstmt.setString(1, newpass); 46 | pstmt.setString(2, userid); 47 | pstmt.setString(3, oldpass); 48 | int i = pstmt.executeUpdate(); 49 | if (i > 0) { 50 | System.out.println("教师修改密码成功"); 51 | out.println("{\"ok\":\"true\",\"msg\":\"修改成功\"}"); 52 | session.setAttribute("logined", null); 53 | } else { 54 | out.println("{\"ok\":\"false\",\"msg\":\"修改失败,可能是原密码错误\"}"); 55 | } 56 | pstmt.close(); 57 | } catch (SQLException e) { 58 | e.printStackTrace(); 59 | out.println("{\"ok\":\"false\"," + 60 | "\"msg\":\"修改失败,数据库错误(" + JDBCUtil.jsonReplace(e.getMessage()) + ")\"}"); 61 | } 62 | } 63 | 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin2/ChangePasswordServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin2; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-01-13-013. 19 | */ 20 | @WebServlet(name = "ChangePasswordServlet", value = "/admin2/pass.do") 21 | public class ChangePasswordServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | response.setContentType("application/json;charset=UTF-8"); 25 | PrintWriter out = response.getWriter(); 26 | //鉴权 27 | String logined = (String) session.getAttribute("logined"); 28 | Integer type = (Integer) session.getAttribute("type"); 29 | if (logined == null || type == null || type != 1) { 30 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 31 | return; 32 | } 33 | // {"ok":"false","msg":"..."} 34 | String name = request.getParameter("name"); 35 | String oldpass = request.getParameter("oldpass"); 36 | String newpass = request.getParameter("newpass"); 37 | if (name == null || oldpass == null || newpass == null 38 | || name.equals("") || oldpass.length() != 32 || newpass.length() != 32) { 39 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 40 | return; 41 | } 42 | Connection con = JDBCUtil.getConnection(); 43 | String sql = "UPDATE admin SET passwd = ? WHERE name = ? AND passwd = ?"; 44 | try { 45 | PreparedStatement pstmt = con.prepareStatement(sql); 46 | pstmt.setString(1, newpass); 47 | pstmt.setString(2, name); 48 | pstmt.setString(3, oldpass); 49 | int i = pstmt.executeUpdate(); 50 | if (i > 0) { 51 | System.out.println("教务更改密码成功"); 52 | session.setAttribute("logined", null); 53 | session.setAttribute("type", -1); 54 | out.println("{\"ok\":\"true\",\"msg\":\"更改成功\"}"); 55 | return; 56 | } else { 57 | out.println("{\"ok\":\"false\",\"msg\":\"原密码错误\"}"); 58 | return; 59 | } 60 | } catch (SQLException e) { 61 | out.println("{\"ok\":\"false\",\"msg\":\"数据库异常:[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 62 | return; 63 | } 64 | } 65 | 66 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /web/teacher/score.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %> 5 | <%@ page import="java.sql.ResultSet" %> 6 | <%@ page import="java.util.*" %><%-- 7 | Created by IntelliJ IDEA. 8 | User: lin 9 | Date: 2016-02-22-022 10 | Time: 14:30 下午 11 | To change this template use File | Settings | File Templates. 12 | --%> 13 | <%@ page trimDirectiveWhitespaces="true" %> 14 | <%@ page pageEncoding="UTF-8" language="java" %> 15 | <%@ include file="../WEB-INF/content/teacher/top.jsp" %> 16 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | <% 30 | Connection con = JDBCUtil.getConnection(); 31 | String sql = "SELECT s_id,s_name,c_id,c_title,tk_score,tk_point,tk_credit " + 32 | " FROM student NATURAL JOIN takes NATURAL JOIN sec NATURAL JOIN course " + 33 | " WHERE t_id = ? AND sec_semester = (SELECT value FROM info WHERE key = 'semester') " + 34 | " ORDER BY s_id, c_id"; 35 | Set course = new LinkedHashSet<>(); 36 | try { 37 | PreparedStatement pstmt = con.prepareStatement(sql); 38 | pstmt.setString(1, (String) session.getAttribute("userId")); 39 | ResultSet rs = pstmt.executeQuery(); 40 | String score; 41 | while (rs.next()) { 42 | if (course.contains(rs.getString("s_id") + rs.getString("c_id"))) { 43 | continue; 44 | } 45 | course.add(rs.getString("s_id") + rs.getString("c_id")); 46 | score = rs.getString("tk_score"); 47 | if (score == null) { 48 | score = ""; 49 | } 50 | out.println(""); 57 | } 58 | } catch (SQLException e) { 59 | e.printStackTrace(); 60 | } 61 | 62 | %> 63 |
学号姓名课程成绩
" + rs.getString("s_id") + "" + rs.getString("s_name") + 51 | "" + rs.getString("c_title") + "
64 |
65 |
66 | <%@ include file="../WEB-INF/content/teacher/bottom.jsp" %> -------------------------------------------------------------------------------- /web/WEB-INF/content/admin/top.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-01-11-011 5 | Time: 15:54 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | <%@ include file="../../../header.jsp" %> 11 | <% 12 | if (type != 0) { 13 | response.sendRedirect(basePath); 14 | return; 15 | } 16 | %> 17 | 超级管理员 - 学生选课系统 18 | 58 | 59 | 60 |
61 | 62 |
63 |

欢迎使用选课系统

64 |
65 | 66 | 93 |
-------------------------------------------------------------------------------- /web/teacher/teacher.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by lin on 2016-02-15-015. 3 | */ 4 | jQuery(document).ready(function ($) { 5 | if (typeof (addmyclass) == "function") { 6 | addmyclass(); 7 | } 8 | //获取公告 9 | $('#notice-detail').on('show.bs.modal', function (event) { 10 | var button = $(event.relatedTarget); 11 | var modal = $(this); 12 | modal.find('#notice-title').html(button.data('noticetitle')); 13 | modal.find('#notice-pubtime').html(button.data('noticepubtime')); 14 | var link = modal.find('#notice-remote-uri').attr('href') 15 | + 'getnoticecontent.do?noticeid=' + button.data('noticeid'); 16 | var contentbody = $('#notice-content'); 17 | jQuery.ajax({ 18 | type: 'GET', 19 | url: link, 20 | beforeSend: function () { 21 | contentbody.html('正在加载...'); 22 | }, 23 | datatype: "html", 24 | success: function (result) { 25 | contentbody.html(result); 26 | }, 27 | error: function (out) { 28 | contentbody.html("很抱歉,发生了错误,获取公告内容失败。+
" + out + "
"); 29 | } 30 | }); 31 | }); 32 | 33 | //上成绩 34 | $('.score-form').submit(function (e) { 35 | var msg = "'; 46 | }, 47 | error: function () { 48 | msg += "出错了
"; 49 | }, 50 | complete: function () { 51 | $('#alert-tip').append(msg).css('top', ($(document.body).height() - $('#alert-tip').height()) / 2); 52 | } 53 | }); 54 | return e.preventDefault(); 55 | }); 56 | 57 | //修改密码 58 | $('#passwd-form').submit(function (e) { 59 | $('#old-pass').val($.md5("Orange" + $('#t-id').val() + $('#old-pass-plain').val())); 60 | $('#new-pass').val($.md5("Orange" + $('#t-id').val() + $('#new-pass-plain').val())); 61 | $.ajax({ 62 | url: $(this).attr('action'), 63 | data: $(this).serialize(), 64 | type: 'POST', 65 | datatype: 'json', 66 | beforeSend: function () { 67 | $('#tip').html(' '); 68 | }, 69 | success: function (r) { 70 | if (r.ok == 'true') { 71 | $('#tip').html(r.msg + '(2秒后跳转)'); 72 | setTimeout(function () { 73 | location.reload(); 74 | }, 2000); 75 | } else { 76 | $('#tip').html(r.msg); 77 | } 78 | }, 79 | error: function () { 80 | $('#tip').html('出错了'); 81 | }, 82 | }); 83 | return e.preventDefault(); 84 | }); 85 | }); -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin/PasswdServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintStream; 13 | import java.io.PrintWriter; 14 | import java.sql.Connection; 15 | import java.sql.PreparedStatement; 16 | import java.sql.SQLException; 17 | 18 | /** 19 | * Created by lin on 2016-01-11-011. 20 | */ 21 | @WebServlet(name = "PasswdServlet", value = "/admin/passwd.do") 22 | public class PasswdServlet extends HttpServlet { 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 24 | HttpSession session = request.getSession(); 25 | response.setContentType("application/json;charset=UTF-8"); 26 | PrintWriter out = response.getWriter(); 27 | // PrintStream out = System.out; 28 | // out.println("POST"); 29 | //鉴权 30 | String logined = (String) session.getAttribute("logined"); 31 | Integer type = (Integer) session.getAttribute("type"); 32 | if (logined == null || type == null || type != 0) { 33 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 34 | return; 35 | } 36 | 37 | String name = request.getParameter("name"); 38 | String oldpass = request.getParameter("oldpass"); 39 | String newpass = request.getParameter("newpass"); 40 | if (name == null || oldpass == null || newpass == null || oldpass.length() != 32 || newpass.length() != 32) { 41 | out.println("{\"ok\":\"false\",\"msg\":\"请检查输入,表单均为必填项\"}"); 42 | return; 43 | } 44 | Connection con = JDBCUtil.getConnection(); 45 | String sql = "UPDATE admin SET passwd = ? WHERE name = ? AND passwd = ?"; 46 | try { 47 | PreparedStatement pstmt = con.prepareStatement(sql); 48 | pstmt.setString(1, newpass); 49 | pstmt.setString(2, name); 50 | pstmt.setString(3, oldpass); 51 | int i = pstmt.executeUpdate(); 52 | if (i > 0) { 53 | session.setAttribute("logined", null); 54 | System.out.println("修改密码成功:" + i + "行受影响"); 55 | out.println("{\"ok\":\"true\",\"msg\":\"修改密码成功\"}"); 56 | } else { 57 | out.println("{\"ok\":\"false\",\"msg\":\"修改密码失败(可能是您输入的原密码不正确)\"}"); 58 | } 59 | } catch (SQLException e) { 60 | out.println("{\"ok\":\"false\",\"msg\":\"修改失败[" + jsonReplace(e.getMessage()) + "]\"}"); 61 | System.out.println("{\"ok\":\"false\",\"msg\":\"修改失败[" + jsonReplace(e.getMessage()) + "]\"}"); 62 | } 63 | } 64 | 65 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 66 | response.getWriter().println("post only"); 67 | } 68 | 69 | private String jsonReplace(String str) { 70 | return str.replace("\"", "\'").replace(":", "_").replace("\n", " "); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /web/WEB-INF/content/user/top.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-02-15-015 5 | Time: 09:07 上午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | <%@ include file="../../../header.jsp" %> 11 | <% 12 | if (type != 3) { 13 | response.sendRedirect(basePath); 14 | return; 15 | } 16 | %> 17 | 首页 - 学生选课系统 18 | 65 | 66 | 67 |
68 |
69 |

欢迎使用选课系统

70 |
71 | 72 | 97 | 98 |
99 | -------------------------------------------------------------------------------- /web/user/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.ResultSet" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.SQLException" %><%-- 4 | Created by IntelliJ IDEA. 5 | User: lin 6 | Date: 2015-12-15-015 7 | Time: 20:03 下午 8 | To change this template use File | Settings | File Templates. 9 | --%> 10 | <%@ page trimDirectiveWhitespaces="true" %> 11 | <%@ page pageEncoding="UTF-8" language="java" %> 12 | <%@ include file="../WEB-INF/content/user/top.jsp" %> 13 | 16 |
17 |

系统公告

18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | <% 28 | ResultSet rs = JDBCUtil.getAllNotice(); 29 | try { 30 | int i = 0; 31 | while (rs.next()) { 32 | if (rs.getString(JDBCUtil.NOTICE_TYPE).contains("3") && i < JDBCUtil.NOTICE_LIMIT) { 33 | %> 34 | 35 | 36 | 45 | 47 | 48 | <% 49 | }//if 50 | }//while 51 | } catch (SQLException e) { 52 | out.println("
colspan=\"3\" class=\"text-danger\">获取公告失败
"); 53 | } 54 | %> 55 | 56 |
#序号标题发布时间
"><%=++i%> 37 | " 41 | data-noticetitle="<%=rs.getString("title")%>" 42 | data-noticeid="<%=rs.getString("id")%>"><%=rs.getString("title")%> 43 | 44 | <%=rs.getString("pubtime")%> 46 |
57 |
58 | 59 | 80 | 81 | 82 | <%@ include file="../WEB-INF/content/user/bottom.jsp" %> -------------------------------------------------------------------------------- /web/WEB-INF/content/teacher/top.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2016-02-15-015 5 | Time: 09:07 上午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | <%@ include file="../../../header.jsp" %> 11 | <% 12 | if (type != 2) { 13 | response.sendRedirect(basePath); 14 | return; 15 | } 16 | %> 17 | 教师首页 - 学生选课系统 18 | 65 | 66 | 67 |
68 |
69 |

欢迎使用选课系统

70 |
71 | 72 | 97 | 98 |
99 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin2/notice.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 2 | <%@ page import="java.sql.ResultSet" %> 3 | <%-- 4 | Created by IntelliJ IDEA. 5 | User: lin 6 | Date: 2015-12-19-019 7 | Time: 20:24 下午 8 | To change this template use File | Settings | File Templates. 9 | --%> 10 | <%@ page trimDirectiveWhitespaces="true" %> 11 | <%@ page pageEncoding="UTF-8" language="java" %> 12 | 13 | <%ResultSet rs = JDBCUtil.getAllNotice();%> 14 |
15 |

系统公告

16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | <% 27 | String basePath1 = request.getScheme() + "://" + request.getServerName() + ":" 28 | + request.getServerPort() + request.getContextPath() + "/"; 29 | int i = 0; 30 | while (rs.next()) { 31 | if (rs.getString(JDBCUtil.NOTICE_TYPE).contains("1") && i < JDBCUtil.NOTICE_LIMIT) { 32 | %> 33 | 34 | 35 | 44 | 48 | 49 | <% 50 | }//if 51 | }//while rs.next 52 | if (i != 0) { 53 | %> 54 | 58 | <% 59 | } 60 | %> 61 | 62 |
#标题发布时间
"><%=++i%> 36 | " 40 | data-noticetitle="<%=rs.getString("title")%>" 41 | data-noticeid="<%=rs.getString("id")%>"><%=rs.getString("title")%> 42 | 43 | 45 | <%=rs.getString("pubtime")%> 46 | 47 |
63 |
64 | 86 | 87 | -------------------------------------------------------------------------------- /web/teacher/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.ResultSet" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.SQLException" %><%-- 4 | Created by IntelliJ IDEA. 5 | User: lin 6 | Date: 2015-12-15-015 7 | Time: 20:02 下午 8 | To change this template use File | Settings | File Templates. 9 | --%> 10 | <%@ page trimDirectiveWhitespaces="true" %> 11 | <%@ page pageEncoding="UTF-8" language="java" %> 12 | <%@ include file="../WEB-INF/content/teacher/top.jsp" %> 13 | 16 |
17 |

系统公告

18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | <% 28 | ResultSet rs = JDBCUtil.getAllNotice(); 29 | try { 30 | int i = 0; 31 | while (rs.next()) { 32 | if (rs.getString(JDBCUtil.NOTICE_TYPE).contains("2") && i < JDBCUtil.NOTICE_LIMIT) { 33 | %> 34 | 35 | 36 | 45 | 47 | 48 | <% 49 | }//if 50 | }//while 51 | } catch (SQLException e) { 52 | out.println("
colspan=\"3\" class=\"text-danger\">获取公告失败
"); 53 | } 54 | %> 55 | 56 |
#序号标题发布时间
"><%=++i%> 37 | " 41 | data-noticetitle="<%=rs.getString("title")%>" 42 | data-noticeid="<%=rs.getString("id")%>"><%=rs.getString("title")%> 43 | 44 | <%=rs.getString("pubtime")%> 46 |
57 |
58 | 59 | 82 | 83 | <%@ include file="../WEB-INF/content/teacher/bottom.jsp" %> 84 | 85 | -------------------------------------------------------------------------------- /web/teacher/courselist.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.SQLException" %> 2 | <%@ page import="java.sql.ResultSet" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 5 | <%@ page import="java.sql.Connection" %><%-- 6 | Created by IntelliJ IDEA. 7 | User: lin 8 | Date: 2016-02-22-022 9 | Time: 13:49 下午 10 | To change this template use File | Settings | File Templates. 11 | --%> 12 | <%@ page trimDirectiveWhitespaces="true" %> 13 | <%@ page pageEncoding="UTF-8" language="java" %> 14 | <%@ include file="../WEB-INF/content/teacher/top.jsp" %> 15 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <% 39 | String lists[][] = new String[12][8]; 40 | for (int i = 0; i < 12; i++) { 41 | for (int j = 0; j < 8; j++) { 42 | lists[i][j] = ""; 43 | } 44 | } 45 | Connection con = JDBCUtil.getConnection(); 46 | String sql = "SELECT c_title,r_name,ts_sweek,ts_eweek,ts_day,ts_sclass,ts_eclass" + 47 | " FROM sec NATURAL JOIN teacher NATURAL JOIN classroom " + 48 | "NATURAL JOIN timeslot NATURAL JOIN course WHERE t_id = ? AND sec_semester = (" + 49 | "SELECT value FROM info WHERE key = 'semester')"; 50 | try { 51 | PreparedStatement pstm = con.prepareStatement(sql); 52 | pstm.setString(1, (String) session.getAttribute("userId")); 53 | ResultSet rs = pstm.executeQuery(); 54 | while (rs.next()) { 55 | //System.out.println(rs.getString("c_title")); 56 | for (int i = Integer.parseInt(rs.getString("ts_sclass")) - 1; 57 | i < Integer.parseInt(rs.getString("ts_eclass")); i++) { 58 | lists[i][Integer.parseInt(rs.getString("ts_day")) - 1] += 59 | rs.getString("c_title") + ";" + rs.getString("ts_sclass") + "-" 60 | + rs.getString("ts_eclass") + "节(" + rs.getString("ts_sweek") + "-" 61 | + rs.getString("ts_eweek") + "周);" + rs.getString("r_name"); 62 | } 63 | } 64 | } catch (SQLException e) { 65 | } 66 | for (int i = 0; i < 12; i++) { 67 | out.print(""); 68 | for (int j = 0; j < 8; j++) { 69 | out.print(""); 70 | } 71 | out.println(""); 72 | } 73 | %> 74 | 75 |
 周一周二周三周四周五周六周日
" + (i + 1) + "" + lists[i][j] + "
76 |
77 | 78 | <%@ include file="../WEB-INF/content/teacher/bottom.jsp" %> 79 | -------------------------------------------------------------------------------- /web/user/courselist.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %> 5 | <%@ page import="java.sql.ResultSet" %><%-- 6 | Created by IntelliJ IDEA. 7 | User: lin 8 | Date: 2016-02-21-021 9 | Time: 15:49 下午 10 | To change this template use File | Settings | File Templates. 11 | --%> 12 | <%@ page trimDirectiveWhitespaces="true" %> 13 | <%@ page pageEncoding="UTF-8" language="java" %> 14 | <%@ include file="../WEB-INF/content/user/top.jsp" %> 15 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <% 39 | String lists[][] = new String[12][8]; 40 | for (int i = 0; i < 12; i++) { 41 | for (int j = 0; j < 8; j++) { 42 | lists[i][j] = ""; 43 | } 44 | } 45 | Connection con = JDBCUtil.getConnection(); 46 | String sql = "SELECT c_title,t_name,r_name,ts_sweek,ts_eweek,ts_day,ts_sclass,ts_eclass" + 47 | " FROM takes NATURAL JOIN sec NATURAL JOIN teacher NATURAL JOIN classroom " + 48 | "NATURAL JOIN timeslot NATURAL JOIN course WHERE s_id = ? AND sec_semester = (" + 49 | "SELECT value FROM info WHERE key = 'semester')"; 50 | try { 51 | PreparedStatement pstm = con.prepareStatement(sql); 52 | pstm.setString(1, (String) session.getAttribute("userId")); 53 | ResultSet rs = pstm.executeQuery(); 54 | while (rs.next()) { 55 | //System.out.println(rs.getString("c_title")); 56 | for (int i = Integer.parseInt(rs.getString("ts_sclass")) - 1; 57 | i < Integer.parseInt(rs.getString("ts_eclass")); i++) { 58 | lists[i][Integer.parseInt(rs.getString("ts_day")) - 1] += 59 | rs.getString("c_title") + ";" + rs.getString("ts_sclass") + "-" 60 | + rs.getString("ts_eclass") + "节(" + rs.getString("ts_sweek") + "-" 61 | + rs.getString("ts_eweek") + "周);" + rs.getString("t_name") 62 | + ";" + rs.getString("r_name"); 63 | } 64 | } 65 | } catch (SQLException e) { 66 | } 67 | 68 | for (int i = 0; i < 12; i++) { 69 | out.print(""); 70 | for (int j = 0; j < 8; j++) { 71 | out.print(""); 72 | } 73 | out.println(""); 74 | } 75 | %> 76 | 77 |
 周一周二周三周四周五周六周日
" + (i + 1) + "" + lists[i][j] + "
78 |
79 | <%@ include file="../WEB-INF/content/user/bottom.jsp" %> 80 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin/view-dept.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-17-017 5 | Time: 12:03 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page import="java.sql.Connection" %> 9 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 10 | <%@ page import="java.sql.Statement" %> 11 | <%@ page import="java.sql.ResultSet" %> 12 | <%@ page trimDirectiveWhitespaces="true" %> 13 | <%@ page pageEncoding="UTF-8" language="java" %> 14 | <% 15 | Connection con = JDBCUtil.getConnection(); 16 | String sql = "SELECT to_char(d_id,'09') as id,d_name FROM department ORDER BY d_id"; 17 | Statement stmt = con.createStatement(); 18 | ResultSet rs = stmt.executeQuery(sql); 19 | %> 20 |
21 |

院系一览

22 |
23 |

添加院系

24 |

编号两位数且不能与已有编号重复, 25 | 名称20个字符(十个汉字)以内且不能与已有名称重复

26 |
27 | 28 | 31 |
32 |
33 | 34 | 37 |
38 | 39 |

 

40 |
41 | 42 |
43 | 44 |

Warning!

Best check yo self, you're not... 45 |
46 | 47 | 52 | 53 |
54 |

(警告:数据库中其他表依赖于院系表,因此除非该院系的所有相关记录均已删除,否则将不能删除院系)

55 | 56 | 57 | 58 | 61 | 62 | 63 | 66 | 67 | 68 | 69 | <% 70 | int i = 0; 71 | while (rs.next()) { 72 | %> 73 | 74 | 76 | 78 | 80 | 81 | 82 | 83 | <% 84 | } 85 | %> 86 | 87 |
59 | 序号 60 | 院系编号院系名称 64 | 删除 65 |
<%=++i%> 75 | <%=rs.getString(1)%> 77 | <%=rs.getString("d_name")%> 79 | ">删除
88 |
89 |
90 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin2/top.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-19-019 5 | Time: 23:04 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page trimDirectiveWhitespaces="true" %> 9 | <%@ page pageEncoding="UTF-8" language="java" %> 10 | <%@ include file="../../../header.jsp" %> 11 | <% 12 | if (type != 1) { 13 | response.sendRedirect(basePath); 14 | return; 15 | } 16 | %> 17 | 教务管理 - 学生选课系统 18 | 73 | 74 | 75 |
76 |
77 |

欢迎使用选课系统

78 |
79 | 80 | 106 | 107 |
108 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin2/AddStudentServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin2; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-01-18-018. 19 | */ 20 | @WebServlet(name = "AddStudentServlet", value = "/admin2/addStudent.do") 21 | public class AddStudentServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | response.setContentType("text/html;charset=UTF-8"); 25 | PrintWriter out = response.getWriter(); 26 | //鉴权 27 | String logined = (String) session.getAttribute("logined"); 28 | Integer types = (Integer) session.getAttribute("type"); 29 | if (logined == null || types == null || types != 1) { 30 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 31 | return; 32 | } 33 | String type = request.getParameter("type"); 34 | String sql = ""; 35 | Connection con = null; 36 | if (type.equals("addOneStu")) { 37 | String id = request.getParameter("id"); 38 | String id2 = request.getParameter("id2"); 39 | String name = request.getParameter("name"); 40 | String gender = request.getParameter("gender"); 41 | String grade = request.getParameter("grade"); 42 | String d_name = (String) session.getAttribute("dept"); 43 | if (id == null || id2 == null || name == null || gender == null || grade == null 44 | || d_name == null || (!gender.equals("M") & !gender.equals("F")) 45 | || grade.trim().length() != 4) { 46 | System.out.println(gender + " " + grade + " " + d_name + gender.equals("M")); 47 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 48 | return; 49 | } 50 | sql = "INSERT INTO student(s_id,s_id2,s_name,s_gender,s_passwd,d_name,s_grade) VALUES (?,?,?,?,?,?,?)"; 51 | con = JDBCUtil.getConnection(); 52 | try { 53 | PreparedStatement pstmt = con.prepareStatement(sql); 54 | pstmt.setString(1, id); 55 | pstmt.setString(2, id2); 56 | pstmt.setString(3, name); 57 | pstmt.setString(4, gender); 58 | pstmt.setString(5, JDBCUtil.MD5("Orange" + id + id)); 59 | pstmt.setString(6, d_name); 60 | pstmt.setString(7, grade); 61 | int i = pstmt.executeUpdate(); 62 | if (i > 0) { 63 | System.out.println("添加单个学生成功"); 64 | out.println("{\"ok\":\"true\",\"msg\":\"添加成功\"}"); 65 | return; 66 | } else { 67 | out.println("{\"ok\":\"false\",\"msg\":\"添加了0条记录\"}"); 68 | return; 69 | } 70 | } catch (SQLException e) { 71 | out.println("{\"ok\":\"false\"," + 72 | "\"msg\":\"添加失败(请检查是否重复添加):[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 73 | // e.printStackTrace(); 74 | return; 75 | } 76 | }//addOneStu 77 | } 78 | 79 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /web/user/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by lin on 2016-02-15-015. 3 | */ 4 | jQuery(document).ready(function ($) { 5 | if (typeof (addmyclass) == "function") { 6 | addmyclass(); 7 | } 8 | //获取公告 9 | $('#notice-detail').on('show.bs.modal', function (event) { 10 | var button = $(event.relatedTarget); 11 | var modal = $(this); 12 | modal.find('#notice-title').html(button.data('noticetitle')); 13 | modal.find('#notice-pubtime').html(button.data('noticepubtime')); 14 | var link = modal.find('#notice-remote-uri').attr('href') 15 | + 'getnoticecontent.do?noticeid=' + button.data('noticeid'); 16 | var contentbody = $('#notice-content'); 17 | jQuery.ajax({ 18 | type: 'GET', 19 | url: link, 20 | beforeSend: function () { 21 | contentbody.html('正在加载...'); 22 | }, 23 | datatype: "html", 24 | success: function (result) { 25 | contentbody.html(result); 26 | }, 27 | error: function (out) { 28 | contentbody.html("很抱歉,发生了错误,获取公告内容失败。+
" + out + "
"); 29 | } 30 | }); 31 | }); 32 | 33 | //选课/退选 34 | $('a.select').click(function (e) { 35 | var a = $(this); 36 | var url = $(this).attr('href'); 37 | var urlbase = url.split('?')[0]; 38 | var selected = false; 39 | if (url.split('?')[1].charAt(9) == 't') { 40 | selected = true; 41 | } 42 | console.log(urlbase + selected); 43 | $.ajax({ 44 | type: 'POST', 45 | url: url, 46 | dataType: 'json', 47 | success: function (r) { 48 | if (r.ok == 'true') { 49 | if (selected) { 50 | //退选 51 | a.html('选课').removeClass('btn-success').addClass('btn-primary'); 52 | a.attr('href', urlbase + '?' + url.split('?')[1].replace(/true/, 'false')); 53 | } else { 54 | //选课 55 | a.html('退选').removeClass('btn-primary').addClass('btn-success'); 56 | a.attr('href', urlbase + '?' + url.split('?')[1].replace(/false/, 'true')); 57 | } 58 | } 59 | }, 60 | error: function () { 61 | }, 62 | }); 63 | return e.preventDefault(); 64 | }); 65 | 66 | //修改密码 67 | $('#user-passwd-form').submit(function (e) { 68 | var msg = "'; 82 | setTimeout(function () { 83 | location.reload(); 84 | }, 2000); 85 | } else msg += r.msg + '
'; 86 | }, 87 | error: function () { 88 | msg += "出错了
"; 89 | }, 90 | complete: function () { 91 | $('#alert-tip').append(msg).css('top', ($(document.body).height() - $('#alert-tip').height()) / 2); 92 | } 93 | }); 94 | return e.preventDefault(); 95 | }); 96 | }); -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/user/CourseSelectionServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.user; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | import java.sql.Statement; 17 | 18 | /** 19 | * Created by lin on 2016-02-21-021. 20 | */ 21 | @WebServlet(name = "CourseSelectionServlet", value = "/user/select.do") 22 | public class CourseSelectionServlet extends HttpServlet { 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 24 | HttpSession session = request.getSession(); 25 | //鉴权 26 | String logined = (String) session.getAttribute("logined"); 27 | Integer type = (Integer) session.getAttribute("type"); 28 | response.setContentType("application/json;charset=UTF-8"); 29 | PrintWriter out = response.getWriter(); 30 | if (logined == null || type == null || type != 3) { 31 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 32 | return; 33 | } 34 | 35 | String sec_id = request.getParameter("sec-id"), 36 | c_id = request.getParameter("cid"); 37 | if (request.getParameter("selected") == null || sec_id == null || c_id == null) 38 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 39 | 40 | Connection con = JDBCUtil.getConnection(); 41 | String sql; 42 | PreparedStatement pstmt; 43 | if (request.getParameter("selected").equals("true")) { 44 | //退选 45 | sql = "DELETE FROM takes WHERE s_id = ? AND c_id = ? AND sec_id = ?"; 46 | try { 47 | pstmt = con.prepareStatement(sql); 48 | pstmt.setString(1, (String) session.getAttribute("userId")); 49 | pstmt.setString(2, c_id); 50 | pstmt.setString(3, sec_id); 51 | int i = pstmt.executeUpdate(); 52 | if (i > 0) { 53 | System.out.println("退选成功" + i); 54 | out.println("{\"ok\":\"true\",\"msg\":\"退选成功\"}"); 55 | pstmt.close(); 56 | return; 57 | } else out.println("{\"ok\":\"false\",\"msg\":\"退选失败\"}"); 58 | pstmt.close(); 59 | } catch (SQLException e) { 60 | e.printStackTrace(); 61 | } 62 | } else { 63 | //选课 64 | sql = "INSERT INTO takes(s_id,c_id,sec_id) VALUES (?,?,?)"; 65 | try { 66 | pstmt = con.prepareStatement(sql); 67 | pstmt.setString(1, (String) session.getAttribute("userId")); 68 | pstmt.setString(2, c_id); 69 | pstmt.setString(3, sec_id); 70 | int i = pstmt.executeUpdate(); 71 | if (i > 0) { 72 | System.out.println("插入记录选课成功" + i + "条记录" + session.getAttribute("userId") + c_id + " " + sec_id); 73 | out.println("{\"ok\":\"true\",\"msg\":\"选课成功\"}"); 74 | pstmt.close(); 75 | return; 76 | } else out.println("{\"ok\":\"false\",\"msg\":\"选课失败\"}"); 77 | pstmt.close(); 78 | } catch (SQLException e) { 79 | e.printStackTrace(); 80 | out.println("{\"ok\":\"false\",\"msg\":\"选课失败[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 81 | } 82 | } 83 | } 84 | 85 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /web/teacher/stulist.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %> 5 | <%@ page import="com.sun.org.apache.regexp.internal.RE" %> 6 | <%@ page import="java.sql.ResultSet" %><%-- 7 | Created by IntelliJ IDEA. 8 | User: lin 9 | Date: 2016-02-22-022 10 | Time: 13:59 下午 11 | To change this template use File | Settings | File Templates. 12 | --%> 13 | <%@ page trimDirectiveWhitespaces="true" %> 14 | <%@ page pageEncoding="UTF-8" language="java" %> 15 | <%@ include file="../WEB-INF/content/teacher/top.jsp" %> 16 | 19 |
20 |
21 | 22 | 50 |
51 |
52 | 53 |
54 |
55 | <% 56 | String secId = request.getParameter("sec"); 57 | if (secId != null) { 58 | 59 | %> 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | <% 72 | try { 73 | PreparedStatement pstmt = con.prepareStatement( 74 | "SELECT s_id,s_id2,s_name,s_gender" + 75 | " FROM student NATURAL JOIN sec NATURAL JOIN takes" + 76 | " WHERE sec_id = ? ORDER BY s_id"); 77 | pstmt.setString(1, secId); 78 | ResultSet rs = pstmt.executeQuery(); 79 | while (rs.next()) { 80 | out.println(""); 83 | } 84 | } catch (SQLException e) { 85 | } 86 | %> 87 | 88 |
学号教学号姓名性别
" + rs.getString("s_id") + "" 81 | + rs.getString("s_id2") + "" + rs.getString("s_name") 82 | + "" + rs.getString("s_gender") + "
89 |
90 | <% 91 | } 92 | %> 93 | <%@ include file="../WEB-INF/content/teacher/bottom.jsp" %> 94 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin/OpenSystemServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.*; 14 | 15 | /** 16 | * Created by lin on 2016-02-19-019. 17 | */ 18 | @WebServlet(name = "OpenSystemServlet", value = "/switch.do") 19 | public class OpenSystemServlet extends HttpServlet { 20 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | HttpSession session = request.getSession(); 22 | //鉴权 23 | String logined = (String) session.getAttribute("logined"); 24 | Integer type = (Integer) session.getAttribute("type"); 25 | response.setContentType("application/json;charset=UTF-8"); 26 | PrintWriter out = response.getWriter(); 27 | if (logined == null || type == null || type != 0) { 28 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 29 | return; 30 | } 31 | String open = request.getParameter("open"); 32 | if (open == null) { 33 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 34 | return; 35 | } 36 | Connection con = JDBCUtil.getConnection(); 37 | if (open.equals("true")) { 38 | try { 39 | Statement stmt = con.createStatement(); 40 | int i = stmt.executeUpdate("UPDATE info SET value = 'true' WHERE key = 'opened'"); 41 | if (i == 0) { 42 | i = stmt.executeUpdate("INSERT INTO info(key,value) VALUES ('opened','true')"); 43 | } 44 | stmt.close(); 45 | } catch (SQLException e) { 46 | e.printStackTrace(); 47 | } 48 | out.println("{\"ok\":\"true\",\"msg\":\"opened\"}"); 49 | } else { 50 | try { 51 | Statement stmt = con.createStatement(); 52 | int i = stmt.executeUpdate("UPDATE info SET value = 'false' WHERE key = 'opened'"); 53 | stmt.close(); 54 | } catch (SQLException e) { 55 | } 56 | out.println("{\"ok\":\"true\",\"msg\":\"notOpen\"}"); 57 | } 58 | } 59 | 60 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 61 | HttpSession session = request.getSession(); 62 | //鉴权 63 | String logined = (String) session.getAttribute("logined"); 64 | Integer type = (Integer) session.getAttribute("type"); 65 | response.setContentType("application/json;charset=UTF-8"); 66 | PrintWriter out = response.getWriter(); 67 | if (logined == null || type == null || type != 0) { 68 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 69 | return; 70 | } 71 | 72 | String semester = request.getParameter("semester"); 73 | if (semester == null) { 74 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 75 | return; 76 | } 77 | Connection con = JDBCUtil.getConnection(); 78 | try { 79 | PreparedStatement pstmt = con.prepareStatement("UPDATE info SET value = ? WHERE key = 'semester'"); 80 | pstmt.setString(1, semester); 81 | int i = pstmt.executeUpdate(); 82 | if (i == 0) { 83 | pstmt = con.prepareStatement("INSERT INTO info(key,value) VALUES ('semester',?)"); 84 | pstmt.setString(1, semester); 85 | i = pstmt.executeUpdate(); 86 | } 87 | pstmt.close(); 88 | out.println("{\"ok\":\"true\",\"msg\":\"" + semester + "\"}"); 89 | } catch (SQLException e) { 90 | e.printStackTrace(); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin/DeptServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | import oracle.sql.NUMBER; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import javax.servlet.http.HttpSession; 12 | import java.io.IOException; 13 | import java.io.PrintWriter; 14 | import java.sql.Connection; 15 | import java.sql.PreparedStatement; 16 | import java.sql.SQLException; 17 | 18 | /** 19 | * Created by lin on 2016-01-11-011. 20 | */ 21 | @WebServlet(name = "DeptServlet", value = "/admin/dept.do") 22 | public class DeptServlet extends HttpServlet { 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 24 | HttpSession session = request.getSession(); 25 | response.setContentType("application/json;charset=UTF-8"); 26 | PrintWriter out = response.getWriter(); 27 | //{"ok":"false","msg":"..."} 28 | //鉴权 29 | String logined = (String) session.getAttribute("logined"); 30 | Integer type = (Integer) session.getAttribute("type"); 31 | if (logined == null || type == null || type != 0) { 32 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 33 | return; 34 | } 35 | Connection con = JDBCUtil.getConnection(); 36 | String d_id = request.getParameter("d-id"); 37 | String d_name = request.getParameter("d-name"); 38 | if (d_id == null || d_name == null || d_id.equals("") || d_name.equals("")) { 39 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误(表单均为必填项)\"}"); 40 | return; 41 | } 42 | String sql = "INSERT INTO department(d_id,d_name) VALUES(?,?)"; 43 | try { 44 | PreparedStatement pstmt = con.prepareStatement(sql); 45 | pstmt.setString(1, d_id); 46 | pstmt.setString(2, d_name); 47 | int i = pstmt.executeUpdate(); 48 | System.out.println("添加院系成功:" + i + "行受影响"); 49 | pstmt.close(); 50 | out.println("{\"ok\":\"true\",\"msg\":\"添加院系成功\"}"); 51 | } catch (SQLException e) { 52 | //e.printStackTrace(); 53 | //{"ok":"false","msg":"添加出错(ORA-00001: 违反唯一约束条件 (OUSER.UQ_D_ID))"} 54 | out.println("{\"ok\":\"false\"," + 55 | "\"msg\":\"添加出错(请检查是否与已有项目重复):[" + jsonReplace(e.getMessage()) + "]\"}"); 56 | } 57 | } 58 | 59 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 60 | HttpSession session = request.getSession(); 61 | response.setContentType("application/json;charset=UTF-8"); 62 | PrintWriter out = response.getWriter(); 63 | //鉴权 64 | String logined = (String) session.getAttribute("logined"); 65 | Integer type = (Integer) session.getAttribute("type"); 66 | if (logined == null || type == null || type != 0) { 67 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 68 | return; 69 | } 70 | String d_id = request.getParameter("d-id"); 71 | if (d_id == null || d_id.equals("")) { 72 | // {"ok":"false","msg":"..."}; 73 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 74 | return; 75 | } 76 | String sql = "DELETE FROM department WHERE d_id = ?"; 77 | Connection con = JDBCUtil.getConnection(); 78 | try { 79 | PreparedStatement pstmt = con.prepareStatement(sql); 80 | pstmt.setString(1, d_id); 81 | int i = pstmt.executeUpdate(); 82 | System.out.println("删除成功:" + i + "行受影响(删除院系)"); 83 | out.println("{\"ok\":\"true\",\"msg\":\"删除院系成功\"}"); 84 | } catch (SQLException e) { 85 | e.printStackTrace(); 86 | out.println("{\"ok\":\"false\"," + 87 | "\"msg\":\"数据库出错(可能是该院系的教师和学生或课程相关没有被删除):" + 88 | "[" + jsonReplace(e.getMessage()) + "]\"}"); 89 | } 90 | } 91 | 92 | private String jsonReplace(String str) { 93 | return str.replace("\"", "\'").replace(":", "_").replace("\n", " "); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin/NoticeServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-01-11-011. 19 | */ 20 | @WebServlet(name = "NoticeServlet", value = "/admin/addNotice.do") 21 | public class NoticeServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | response.setContentType("application/json;charset=UTF-8"); 25 | PrintWriter out = response.getWriter(); 26 | 27 | //{"ok":"false","msg":"..."} 28 | 29 | //鉴权 30 | String logined = (String) session.getAttribute("logined"); 31 | Integer type = (Integer) session.getAttribute("type"); 32 | if (logined == null || type == null || type != 0) { 33 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 34 | return; 35 | } 36 | 37 | String title = request.getParameter("title"); 38 | String content = request.getParameter("content"); 39 | String admin2 = request.getParameter("admin2"); 40 | String teacher = request.getParameter("teacher"); 41 | String student = request.getParameter("student"); 42 | String readtype = ""; 43 | if (admin2 != null) { 44 | readtype += "1"; 45 | } 46 | if (teacher != null) { 47 | readtype += "2"; 48 | } 49 | if (student != null) { 50 | readtype += "3"; 51 | } 52 | if (title == null || content == null || title.equals("") || content.equals("") || readtype.equals("")) { 53 | out.println("{\"ok\":\"false\",\"msg\":\"请检查表单(标题,内容均不能为空;角色至少勾选一项)\"}"); 54 | return; 55 | } 56 | /**1.自动增加ID;2.当前时间 57 | * 首先(在SQLPlus里)创建序列, 58 | *
 59 |          *  create sequence notice_id_sequence increment by 1 start with 1 nomaxvalue nocycle cache 10;
 60 |          * 
61 | * sysdate表示当前时间 62 | * */ 63 | String sql = "INSERT INTO notice values(notice_id_sequence.nextval,?,?,sysdate,?)"; 64 | Connection con = JDBCUtil.getConnection(); 65 | try { 66 | PreparedStatement pstmt = con.prepareStatement(sql); 67 | pstmt.setString(1, title); 68 | pstmt.setString(2, content); 69 | pstmt.setString(3, readtype); 70 | int i = pstmt.executeUpdate(); 71 | System.out.println(i + "行受影响:添加公告成功"); 72 | pstmt.close(); 73 | out.println("{\"ok\":\"true\",\"msg\":\"\"}"); 74 | } catch (SQLException e) { 75 | e.printStackTrace(); 76 | out.println("{\"ok\":\"false\",\"msg\":\"数据库出错\"}"); 77 | } 78 | } 79 | 80 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 81 | HttpSession session = request.getSession(); 82 | response.setContentType("application/json;charset=UTF-8"); 83 | PrintWriter out = response.getWriter(); 84 | 85 | //{"ok":"false","msg":"..."} 86 | 87 | //鉴权 88 | String logined = (String) session.getAttribute("logined"); 89 | Integer type = (Integer) session.getAttribute("type"); 90 | if (logined == null || type == null || type != 0) { 91 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 92 | return; 93 | } 94 | String id = request.getParameter("id"); 95 | if (id == null || id.equals("")) { 96 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 97 | return; 98 | } 99 | String sql = "DELETE FROM notice WHERE id = ?"; 100 | Connection con = JDBCUtil.getConnection(); 101 | try { 102 | PreparedStatement pstmt = con.prepareStatement(sql); 103 | pstmt.setString(1, id); 104 | int i = pstmt.executeUpdate(); 105 | System.out.println("删除了" + i + "行:删除公告"); 106 | pstmt.close(); 107 | out.println("{\"ok\":\"true\",\"msg\":\"删除成功\"}"); 108 | } catch (SQLException e) { 109 | e.printStackTrace(); 110 | out.println("{\"ok\":\"false\",\"msg\":\"数据库出错\"}"); 111 | } 112 | 113 | }//doGet 114 | } 115 | -------------------------------------------------------------------------------- /web/admin2/uploadfile.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.io.FileReader" %> 2 | <%@ page import="org.apache.commons.csv.CSVRecord" %> 3 | <%@ page import="java.io.Reader" %> 4 | <%@ page import="org.apache.commons.csv.CSVFormat" %> 5 | <%@ page import="java.io.FileNotFoundException" %> 6 | <%@ page import="java.io.IOException" %> 7 | <%@ page import="java.sql.Connection" %> 8 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 9 | <%@ page import="java.sql.PreparedStatement" %> 10 | <%@ page import="java.sql.SQLException" %> 11 | <%@ page import="java.sql.ResultSet" %> 12 | <%-- 13 | Created by IntelliJ IDEA. 14 | User: lin 15 | Date: 2016-01-09-009 16 | Time: 12:50 下午 17 | To change this template use File | Settings | File Templates. 18 | --%> 19 | <%@ page pageEncoding="UTF-8" trimDirectiveWhitespaces="true" language="java" errorPage="../error.jsp" %> 20 | <% 21 | if (!request.getMethod().toLowerCase().equals("post")) { 22 | return; 23 | } 24 | %> 25 | <%! 26 | //http://bbs.csdn.net/topics/70473069 27 | //jsp里面的函数不能用out.print吗? 28 | private String parseSCV(String file, JspWriter out, String d_name) throws java.io.IOException, SQLException { 29 | String msg = ""; 30 | String sql = "INSERT INTO teacher(t_id,t_name,t_level,t_email,t_passwd,d_name) VALUES(?,?,?,?,?,?)"; 31 | Connection con = JDBCUtil.getConnection(); 32 | int i = 0; 33 | try { 34 | PreparedStatement pstmt = con.prepareStatement(sql); 35 | Reader in = new FileReader(file); 36 | // 加上withHeader(),否则record.get报错 37 | // No header mapping was specified, the record values can't be accessed by name 38 | //http://stackoverflow.com/questions/27323639/no-header-mapping-was-specified-the-record-values-cant-be-accessed-by-name-ap 39 | Iterable records = CSVFormat.EXCEL.withHeader().parse(in); 40 | for (CSVRecord record : records) { 41 | pstmt.setString(1, record.get("工作证号")); 42 | pstmt.setString(2, record.get("姓名")); 43 | pstmt.setString(3, record.get("职称")); 44 | pstmt.setString(4, record.get("邮箱")); 45 | pstmt.setString(5, JDBCUtil.MD5("Orange" + record.get("工作证号") + record.get("工作证号"))); 46 | pstmt.setString(6, d_name); 47 | i += pstmt.executeUpdate(); 48 | out.println("" + record.get("工作证号") + "" 49 | + record.get("姓名") + "" 50 | + record.get("职称") + "" 51 | + record.get("邮箱") + ""); 52 | } 53 | System.out.println(i + "行已插入"); 54 | } catch (FileNotFoundException e) { 55 | msg = "FileNotFoundException" + e.getMessage(); 56 | } catch (IOException e) { 57 | msg = "IOException" + e.getMessage(); 58 | } catch (Exception e) { 59 | msg = "发生了异常" + e.getMessage(); 60 | e.printStackTrace(); 61 | } 62 | return msg; 63 | } 64 | %> 65 |
66 | <% 67 | String msg = (String) session.getAttribute("message"); 68 | if (msg != null) { 69 | out.print("
" + msg + "
"); 70 | session.setAttribute("message", null); 71 | } 72 | String filename = (String) session.getAttribute("filename"); 73 | System.out.println(filename); 74 | if (filename != null && !filename.equals("")) { 75 | Connection con = JDBCUtil.getConnection(); 76 | String sql = "SELECT d_name FROM admin WHERE name = ?"; 77 | PreparedStatement pstmt = con.prepareStatement(sql); 78 | pstmt.setString(1, (String) session.getAttribute("logined")); 79 | ResultSet rs = pstmt.executeQuery(); 80 | String d_name = ""; 81 | while (rs.next()) { 82 | d_name = rs.getString("d_name"); 83 | break; 84 | } 85 | %> 86 |
87 |

上传内容

88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | <% 99 | String result = parseSCV(filename, out, d_name); 100 | %> 101 | 102 |
工作证号姓名职称邮箱
103 |
104 |

<%=result%>

2秒后页面重新加载...

105 | 106 | <% 107 | }//filename != "" 108 | %> 109 |
110 | -------------------------------------------------------------------------------- /web/user/passwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %> 5 | <%@ page import="java.sql.ResultSet" %><%-- 6 | Created by IntelliJ IDEA. 7 | User: lin 8 | Date: 2016-02-19-019 9 | Time: 13:58 下午 10 | To change this template use File | Settings | File Templates. 11 | --%> 12 | <%@ page trimDirectiveWhitespaces="true" %> 13 | <%@ page pageEncoding="UTF-8" language="java" %> 14 | <%@ include file="../WEB-INF/content/user/top.jsp" %> 15 | 18 |
19 |
20 | 30 |
32 |
33 |
34 | 35 | <% 36 | Connection con = JDBCUtil.getConnection(); 37 | try { 38 | PreparedStatement pstmt = con.prepareStatement("SELECT * FROM student WHERE s_id = ?"); 39 | pstmt.setString(1, (String) session.getAttribute("userId")); 40 | ResultSet rs = pstmt.executeQuery(); 41 | while (rs.next()) { 42 | out.println(""); 43 | out.println(""); 44 | out.println(""); 45 | out.println(""); 46 | out.println(""); 47 | out.println(""); 48 | } 49 | } catch (SQLException e) { 50 | out.println(""); 51 | } 52 | %> 53 |
姓名" + rs.getString("s_name") + "
学号" + rs.getString("s_id") + "
教学号" + rs.getString("s_id2") + "
学院" + rs.getString("d_name") + "
性别" + rs.getString("s_gender") + "
年级" + rs.getString("s_grade") + "
查询数据库出错了
54 |
55 |
56 |
57 |
58 | 59 |
60 | 70 |
72 |
73 |
74 |
75 | "> 76 | 77 | 78 | 79 |
80 |
81 | 82 | 83 | 84 |
85 |
86 | 87 |
88 |

提示:修改密码后需要重新登录。

89 |
90 |
91 |
92 |
93 |
94 | <%@ include file="../WEB-INF/content/user/bottom.jsp" %> 95 | -------------------------------------------------------------------------------- /web/user/score.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.sql.Connection" %> 2 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 3 | <%@ page import="java.sql.PreparedStatement" %> 4 | <%@ page import="java.sql.SQLException" %> 5 | <%@ page import="java.sql.ResultSet" %> 6 | <%@ page import="java.util.*" %><%-- 7 | Created by IntelliJ IDEA. 8 | User: lin 9 | Date: 2016-02-21-021 10 | Time: 15:51 下午 11 | To change this template use File | Settings | File Templates. 12 | --%> 13 | <%@ page trimDirectiveWhitespaces="true" %> 14 | <%@ page pageEncoding="UTF-8" language="java" %> 15 | <%@ include file="../WEB-INF/content/user/top.jsp" %> 16 | 19 | 20 |
21 |
22 | 23 | 48 |
49 |
50 | 51 |
52 |
53 |
54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | <%! 65 | String replaceNull(String string) { 66 | if (string == null) 67 | string = ""; 68 | return string; 69 | } 70 | %> 71 | <% 72 | String semester = request.getParameter("semester"); 73 | Map courseList = new HashMap(); 74 | if (semester != null) { 75 | Connection con = JDBCUtil.getConnection(); 76 | String sql = "SELECT s_id,c_id,sec_id,c_title,tk_score,tk_point,tk_credit,sec_semester" + 77 | " FROM takes NATURAL JOIN course NATURAL JOIN sec WHERE sec_semester = ? AND s_id = ?ORDER BY sec_id"; 78 | try { 79 | PreparedStatement pstmt = con.prepareStatement(sql); 80 | pstmt.setString(1, semester); 81 | pstmt.setString(2, (String) session.getAttribute("userId")); 82 | ResultSet rs = pstmt.executeQuery(); 83 | while (rs.next()) { 84 | courseList.put(rs.getString("c_title"), ""); 88 | /*out.println("");*/ 92 | } 93 | } catch (SQLException e) { 94 | 95 | } 96 | } 97 | Iterator iter = courseList.entrySet().iterator(); 98 | while (iter.hasNext()) { 99 | Map.Entry entry = (Map.Entry) iter.next(); 100 | out.println(entry.getValue()); 101 | } 102 | %> 103 |
课程成绩绩点学分
" + rs.getString("c_title") 85 | + "" + replaceNull(rs.getString("tk_score")) + "" 86 | + replaceNull(rs.getString("tk_point")) + "" 87 | + replaceNull(rs.getString("tk_credit")) + "
" + rs.getString("sec_id") + "" + rs.getString("c_title") 89 | + "" + replaceNull(rs.getString("tk_score")) + "" 90 | + replaceNull(rs.getString("tk_point")) + "" 91 | + replaceNull(rs.getString("tk_credit")) + "
104 |
105 | <%@ include file="../WEB-INF/content/user/bottom.jsp" %> 106 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/JDBCUtil.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import java.io.InputStream; 5 | import java.security.MessageDigest; 6 | import java.security.NoSuchAlgorithmException; 7 | import java.sql.*; 8 | import java.util.Properties; 9 | 10 | public class JDBCUtil { 11 | static String driver = "oracle.jdbc.driver.OracleDriver"; 12 | static String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl"; 13 | static String user = "ouser"; 14 | static String pass = "Ozszs233"; 15 | static Connection con = null; 16 | 17 | static { 18 | try { 19 | InputStream in = JDBCUtil.class.getClassLoader().getResourceAsStream("cn/edu/jlu/orange/config.properties"); 20 | Properties config = new Properties(); 21 | config.load(in); 22 | driver = config.getProperty("driver"); 23 | url = config.getProperty("url"); 24 | user = config.getProperty("user"); 25 | pass = config.getProperty("pass"); 26 | System.out.println("读取配置文件完成"); 27 | } catch (Exception e) { 28 | System.out.println("读取配置文件出错,将使用默认配置"); 29 | e.printStackTrace(); 30 | driver = "oracle.jdbc.driver.OracleDriver"; 31 | url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl"; 32 | user = "ouser"; 33 | pass = "Ozszs233"; 34 | } 35 | } 36 | 37 | public static Connection getConnection() { 38 | if (con != null) return con; 39 | try { 40 | Class.forName(driver); 41 | con = DriverManager.getConnection(url, user, pass); 42 | System.out.println("已获取数据库连接"); 43 | } catch (Exception e) { 44 | System.out.println("连接到数据库时出现异常"); 45 | } 46 | return con; 47 | } 48 | 49 | public static void closeConnection() { 50 | if (con == null) return; 51 | try { 52 | con.close(); 53 | con = null; 54 | } catch (SQLException e) { 55 | System.out.println("关闭数据库连接时出现异常"); 56 | } 57 | } 58 | 59 | /** 60 | * java MD5加密 61 | * http://zhidao.baidu.com/questions/181935414.html 62 | * 63 | * @date 2015-12-17 64 | */ 65 | public static String MD5(String str) { 66 | try { 67 | MessageDigest md = MessageDigest.getInstance("MD5"); 68 | md.update(str.getBytes()); 69 | byte b[] = md.digest(); 70 | int i; 71 | StringBuffer sb = new StringBuffer(""); 72 | for (int offset = 0; offset < b.length; offset++) { 73 | i = b[offset]; 74 | if (i < 0) i += 256; 75 | if (i < 16) sb.append("0"); 76 | sb.append(Integer.toHexString(i)); 77 | } 78 | return sb.toString(); 79 | } catch (NoSuchAlgorithmException e) { 80 | e.printStackTrace(); 81 | } 82 | return null; 83 | } 84 | 85 | public static String NOTICE_TYPE = "type"; 86 | public static int NOTICE_LIMIT = 10; 87 | 88 | public static ResultSet getAllNotice() { 89 | Connection con = JDBCUtil.getConnection(); 90 | //id,title,content,pubtime,type 91 | String sql = "SELECT * FROM notice ORDER BY pubtime DESC"; 92 | try { 93 | Statement stmt = con.createStatement(); 94 | return stmt.executeQuery(sql); 95 | } catch (SQLException e) { 96 | System.out.println("获取公告失败"); 97 | } 98 | return null; 99 | } 100 | 101 | public static String getNoticeById(String id) { 102 | String notice = "获取公告内容失败"; 103 | Connection con = JDBCUtil.getConnection(); 104 | try { 105 | String sql = "SELECT content,type FROM notice WHERE id = ?"; 106 | PreparedStatement pstmt = con.prepareStatement(sql); 107 | //java.sql.SQLException: 索引中丢失 IN 或 OUT 参数:: 1 108 | //http://blog.csdn.net/zjx2388/article/details/2077894 109 | //没有setInt或者用的是setString不匹配 110 | pstmt.setInt(1, Integer.parseInt(id)); 111 | ResultSet rs = pstmt.executeQuery(); 112 | //java.sql.SQLException: 未调用 ResultSet.next 113 | while (rs.next()) { 114 | notice = "" + rs.getString("content"); 115 | } 116 | } catch (SQLException e) { 117 | e.printStackTrace(); 118 | System.out.println("获取公告内容失败"); 119 | } 120 | return notice; 121 | } 122 | 123 | public static String jsonReplace(String str) { 124 | return str.replace("\"", "\\\"").replace(":", "_").replace("\n", "."); 125 | } 126 | 127 | public static void main(String[] argv) { 128 | System.out.println(JDBCUtil.MD5("Orangeorangeorange")); 129 | } 130 | 131 | //JSP 获取真实IP地址的代码 132 | //http://www.jb51.net/article/21272.htm 133 | public static String getIp(HttpServletRequest request) { 134 | String ip = request.getHeader("x-forwarded-for"); 135 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 136 | ip = request.getHeader("Proxy-Client-IP"); 137 | } 138 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 139 | ip = request.getHeader("WL-Proxy-Client-IP"); 140 | } 141 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 142 | ip = request.getRemoteAddr(); 143 | } 144 | return ip; 145 | } 146 | 147 | } -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/IPServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.imageio.ImageIO; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.awt.*; 12 | import java.awt.font.FontRenderContext; 13 | import java.awt.geom.Rectangle2D; 14 | import java.awt.image.BufferedImage; 15 | import java.awt.image.ImageConsumer; 16 | import java.io.File; 17 | import java.io.IOException; 18 | import java.io.OutputStream; 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | 22 | /** 23 | * Created by lin on 2016-01-27-027. 24 | */ 25 | @WebServlet(name = "IPServlet", value = "/ip.png") 26 | public class IPServlet extends HttpServlet { 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 28 | doGet(request, response); 29 | } 30 | 31 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 32 | try { 33 | response.setContentType("image/png"); 34 | String w = request.getParameter("w"); 35 | String h = request.getParameter("h"); 36 | String s = request.getParameter("s"); 37 | String c = request.getParameter("c"); 38 | int width = 300, height = 60, size = 18; 39 | if (s != null) { 40 | try { 41 | size = Integer.parseInt(s); 42 | } catch (Exception e) { 43 | } 44 | } 45 | 46 | Font font = new Font("微软雅黑", Font.PLAIN, size); 47 | BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 48 | Graphics2D gd = img.createGraphics(); 49 | gd.setFont(font); 50 | 51 | String ip = JDBCUtil.getIp(request); 52 | //ip = "1234::1234::1234::1234::1234::1234::1234::1234"; 53 | Date date = new Date(); 54 | //Java String和Date的转换 55 | //http://www.cnblogs.com/bmbm/archive/2011/12/06/2342264.html 56 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss (z) E"); 57 | String d = sdf.format(date); 58 | String me = "Powered By Youth.霖"; 59 | 60 | double ipW = getWidth(font, ip, gd.getFontRenderContext()), 61 | ipH = getHeight(font, ip, gd.getFontRenderContext()), 62 | dateW = getWidth(font, d, gd.getFontRenderContext()), 63 | dateH = getHeight(font, d, gd.getFontRenderContext()), 64 | meW = getWidth(font, me, gd.getFontRenderContext()), 65 | meH = getHeight(font, me, gd.getFontRenderContext()); 66 | 67 | width = (int) ipW; 68 | if (dateW > width) width = (int) dateW; 69 | if (meW > width) width = (int) meW; 70 | width += 2; 71 | height = (int) (ipH + dateH + meH + 2); 72 | 73 | if (w != null) { 74 | width = Integer.parseInt(w); 75 | } 76 | if (h != null) { 77 | height = Integer.parseInt(h); 78 | } 79 | 80 | //Java生成透明背景图片 81 | //http://snkcxy.iteye.com/blog/1872229 82 | img = gd.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); 83 | gd = img.createGraphics(); 84 | gd.setFont(font); 85 | //随机颜色 86 | Color color = new Color( 87 | (new Double(Math.random() * 128)).intValue() + 128, 88 | (new Double(Math.random() * 128)).intValue() + 128, 89 | (new Double(Math.random() * 128)).intValue() + 128); 90 | if (c != null) { 91 | try { 92 | //Java中颜色的String和Color对象之间的互相转换 93 | //http://winhack.iteye.com/blog/1843781 94 | color = new Color(Integer.parseInt(c, 16)); 95 | } catch (Exception e) { 96 | } 97 | } 98 | gd.setColor(color); 99 | gd.drawRect(0, 0, width - 1, height - 1); 100 | 101 | gd.drawString(d, (float) ((width - dateW) / 2), (float) (height / 3)); 102 | gd.drawString(ip, (float) ((width - ipW) / 2), (float) (height / 3 * 2)); 103 | gd.drawString(me, (float) (width - meW) / 2, (float) (height - 3)); 104 | ImageIO.write(img, "png", response.getOutputStream()); 105 | } catch (Exception e) { 106 | //e.printStackTrace(); 107 | System.out.print(e.getMessage()); 108 | } 109 | } 110 | 111 | /** 112 | * //计算字符串的像素长度与高度 113 | * //http://blog.chinaunix.net/uid-79084-id-97205.html 114 | * Graphics2D g = (Graphics2D)Toolkit.getDefaultToolkit().getImage("imgname").getGraphics(); 115 | * //设置大字体 116 | * Font font = new Font("楷体", Font.ITALIC | Font.BOLD, 72); 117 | * g.setFont(font); 118 | * FontRenderContext context = g.getFontRenderContext(); 119 | * //获取字体的像素范围对象 120 | * Rectangle2D stringBounds = font.getStringBounds("text", context); 121 | * double fontWidth = stringBounds.getWidth(); 122 | */ 123 | private double getWidth(Font f, String str, FontRenderContext context) { 124 | return f.getStringBounds(str, context).getWidth(); 125 | } 126 | 127 | private double getHeight(Font f, String s, FontRenderContext c) { 128 | return f.getStringBounds(s, c).getHeight(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /web/user/Select.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 2 | <%@ page import="java.sql.*" %><%-- 3 | Created by IntelliJ IDEA. 4 | User: lin 5 | Date: 2016-02-19-019 6 | Time: 16:24 下午 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page trimDirectiveWhitespaces="true" %> 10 | <%@ page pageEncoding="UTF-8" language="java" %> 11 | <%@ include file="../WEB-INF/content/user/top.jsp" %> 12 | 15 | <% 16 | Connection con = JDBCUtil.getConnection(); 17 | boolean opened = false; 18 | String s_grade = ""; 19 | try { 20 | Statement stmt = con.createStatement(); 21 | //region 检查是否开放选课 22 | ResultSet rs = stmt.executeQuery("SELECT * FROM info WHERE key = 'opened'"); 23 | while (rs.next()) { 24 | if (rs.getString("value").equals("true")) 25 | opened = true; 26 | }//endregion 27 | //region 获得用户的年级 28 | rs = stmt.executeQuery("SELECT s_grade FROM student WHERE s_id = " + session.getAttribute("userId")); 29 | while (rs.next()) { 30 | s_grade = rs.getString("s_grade"); 31 | }//endregion 32 | rs.close(); 33 | stmt.close(); 34 | } catch (SQLException e) { 35 | } 36 | if (opened) { 37 | %> 38 |
39 | 40 |

可选课程列表

41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | <%! 53 | boolean hastake(String s_id, String sec_id) { 54 | Connection con = JDBCUtil.getConnection(); 55 | try { 56 | PreparedStatement pstmt = con.prepareStatement( 57 | "SELECT s_id FROM takes WHERE s_id = ? AND sec_id = ?"); 58 | pstmt.setString(1, s_id); 59 | pstmt.setString(2, sec_id); 60 | ResultSet rs = pstmt.executeQuery(); 61 | while (rs.next()) { 62 | rs.close(); 63 | pstmt.close(); 64 | return true; 65 | } 66 | rs.close(); 67 | pstmt.close(); 68 | return false; 69 | } catch (SQLException e) { 70 | e.printStackTrace(); 71 | } 72 | return false; 73 | } 74 | %> 75 | <% 76 | //region 获得用户可选的所有课程 77 | //SELECT sec_id,c_title,sec_semester,sec_creadits,sec_type,t_name,sec_depts,s_grade, 78 | // r_name,ts_sweek,ts_eweek,ts_day,ts_sclass,ts_eclass FROM sec natural join course 79 | // natural join teacher natural join classroom natural join timeslot 80 | // WHERE sec_depts LIKE '%软件学院%' AND s_grade = '2013' 81 | String sql = "SELECT sec_id,c_id,c_title,sec_semester,sec_creadits,sec_type,t_id,t_name," + 82 | "sec_depts,s_grade,r_name,ts_sweek,ts_eweek,ts_day,ts_sclass,ts_eclass " + 83 | " FROM sec natural join course natural join teacher natural join classroom natural join" + 84 | " timeslot WHERE sec_depts LIKE ? AND s_grade = ? AND sec_semester = (" + 85 | "SELECT value FROM info WHERE key = 'semester') ORDER BY sec_id"; 86 | try { 87 | PreparedStatement pstmt = con.prepareStatement(sql); 88 | pstmt.setString(1, "%" + session.getAttribute("dept") + "%"); 89 | pstmt.setString(2, s_grade); 90 | ResultSet rs = pstmt.executeQuery(); 91 | String btn; 92 | while (rs.next()) { 93 | btn = "选课"; 96 | if (hastake((String) session.getAttribute("userId"), rs.getString("sec_id"))) { 97 | btn = "退选"; 100 | } 101 | //System.out.println("可选列表:" + rs.getString("c_title")); 102 | out.println(""); 108 | } 109 | } catch (SQLException e) { 110 | 111 | }//endregion 112 | %> 113 | 114 |
选课编号课程教师学分类型时间地点
" + btn + "" + rs.getString("sec_id") + "" 103 | + rs.getString("c_title") + "" + rs.getString("t_name") + "" 104 | + rs.getString("sec_creadits") + "学分;" + rs.getString("sec_type") + "第" 105 | + rs.getString("ts_sweek") + "-" + rs.getString("ts_eweek") + "周;星期" 106 | + rs.getString("ts_day") + ";第" + rs.getString("ts_sclass") + "-" 107 | + rs.getString("ts_eclass") + "节
115 | 当前课表查看 116 |
117 | <% 118 | } else { 119 | out.print("当前未开放选课"); 120 | } 121 | %> 122 | <%@ include file="../WEB-INF/content/user/bottom.jsp" %> -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin2/ResetOrDeleteTeacherServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin2; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-01-12-012. 19 | */ 20 | @WebServlet(name = "ResetOrDeleteTeacherServlet", value = "/admin2/resetOrDelete.do") 21 | public class ResetOrDeleteTeacherServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | response.setContentType("application/json;charset=UTF-8"); 25 | PrintWriter out = response.getWriter(); 26 | //鉴权 27 | String logined = (String) session.getAttribute("logined"); 28 | Integer type = (Integer) session.getAttribute("type"); 29 | if (logined == null || type == null || type != 1) { 30 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 31 | return; 32 | } 33 | //参数 34 | String id = request.getParameter("t-id"), 35 | name = request.getParameter("t-name"), 36 | level = request.getParameter("t-level"), 37 | email = request.getParameter("t-email"); 38 | if (id == null || name == null || level == null || email == null) { 39 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 40 | return; 41 | } 42 | Connection con = JDBCUtil.getConnection(); 43 | String sql = " UPDATE teacher SET t_name = ? , t_level = ? , t_email = ? " + 44 | " WHERE t_id = ? AND d_name = ? "; 45 | 46 | PreparedStatement pstmt; 47 | try { 48 | pstmt = con.prepareStatement(sql); 49 | pstmt.setString(1, name); 50 | pstmt.setString(2, level); 51 | pstmt.setString(3, email); 52 | pstmt.setString(4, id); 53 | pstmt.setString(5, (String) session.getAttribute("dept")); 54 | int i = pstmt.executeUpdate(); 55 | if (i > 0) { 56 | System.out.println(session.getAttribute("logined") + "(教务)修改" + name + "(教师)资料成功"); 57 | out.println("{\"ok\":\"true\",\"msg\":\"修改成功\"}"); 58 | return; 59 | } 60 | } catch (SQLException e) { 61 | out.println("{\"ok\":\"false\"" + 62 | ",\"msg\":\"执SQL语句发生了异常:[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 63 | return; 64 | } 65 | 66 | } 67 | 68 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 69 | HttpSession session = request.getSession(); 70 | response.setContentType("application/json;charset=UTF-8"); 71 | PrintWriter out = response.getWriter(); 72 | //鉴权 73 | String logined = (String) session.getAttribute("logined"); 74 | Integer type = (Integer) session.getAttribute("type"); 75 | if (logined == null || type == null || type != 1) { 76 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 77 | return; 78 | } 79 | // {"ok":"false","msg":"..."} 80 | String target = request.getParameter("type"); 81 | String id = request.getParameter("id"); 82 | if (target == null || id == null || target.equals("") || id.equals("")) { 83 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 84 | return; 85 | } 86 | Connection con = JDBCUtil.getConnection(); 87 | PreparedStatement pstmt = null; 88 | String sql; 89 | //重置 90 | if (target.equals("0")) { 91 | sql = "UPDATE teacher SET t_passwd = ? WHERE t_id = ?"; 92 | try { 93 | pstmt = con.prepareStatement(sql); 94 | pstmt.setString(1, JDBCUtil.MD5("Orange" + id + id)); 95 | pstmt.setString(2, id); 96 | int i = pstmt.executeUpdate(); 97 | System.out.println("重置密码:" + i + "行受影响"); 98 | if (i > 0) { 99 | out.println("{\"ok\":\"true\",\"msg\":\"重置密码成功\"}"); 100 | return; 101 | } 102 | } catch (SQLException e) { 103 | out.println("{\"ok\":\"false\"," + 104 | "\"msg\":\"数据库异常" + JDBCUtil.jsonReplace(e.getMessage()) + "\"}"); 105 | return; 106 | } 107 | } 108 | //删除 109 | else if (target.equals("1")) { 110 | sql = "DELETE FROM teacher WHERE t_id = ?"; 111 | try { 112 | pstmt = con.prepareStatement(sql); 113 | pstmt.setString(1, id); 114 | int i = pstmt.executeUpdate(); 115 | System.out.println("删除教师:" + i + "行受影响"); 116 | if (i > 0) { 117 | out.println("{\"ok\":\"true\",\"msg\":\"删除成功\"}"); 118 | return; 119 | } 120 | } catch (SQLException e) { 121 | out.println("{\"ok\":\"false\",\"msg\":\"删除失败(可能是有其他约束关系尚未删除):" + 122 | "[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 123 | return; 124 | } 125 | }//delete 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /web/js/user.js: -------------------------------------------------------------------------------- 1 | /*https://github.com/placemarker/jQuery-MD5/blob/master/jquery.md5.js*/(function(f){function n(t,w){var v=(t&65535)+(w&65535),u=(t>>16)+(w>>16)+(v>>16);return(u<<16)|(v&65535)}function r(t,u){return(t<>>(32-u))}function c(A,w,v,u,z,y){return n(r(n(n(w,A),n(u,y)),z),v)}function b(w,v,B,A,u,z,y){return c((v&B)|((~v)&A),w,v,u,z,y)}function h(w,v,B,A,u,z,y){return c((v&A)|(B&(~A)),w,v,u,z,y)}function m(w,v,B,A,u,z,y){return c(v^B^A,w,v,u,z,y)}function a(w,v,B,A,u,z,y){return c(B^(v|(~A)),w,v,u,z,y)}function d(E,z){E[z>>5]|=128<<((z)%32);E[(((z+64)>>>9)<<4)+14]=z;var v,y,w,u,t,D=1732584193,C=-271733879,B=-1732584194,A=271733878;for(v=0;v>5]>>>(v%32))&255)}return t}function i(u){var v,t=[];t[(u.length>>2)-1]=undefined;for(v=0;v>5]|=(u.charCodeAt(v/8)&255)<<(v%32)}return t}function j(t){return o(d(i(t),t.length*8))}function e(v,y){var u,x=i(v),t=[],w=[],z;t[15]=w[15]=undefined;if(x.length>16){x=d(x,v.length*8)}for(u=0;u<16;u+=1){t[u]=x[u]^909522486;w[u]=x[u]^1549556828}z=d(t.concat(i(y)),512+y.length*8);return o(d(w.concat(z),512+128))}function s(v){var y="0123456789abcdef",u="",t,w;for(w=0;w>>4)&15)+y.charAt(t&15)}return u}function l(t){return unescape(encodeURIComponent(t))}function p(t){return j(l(t))}function k(t){return s(p(t))}function g(t,u){return e(l(t),l(u))}function q(t,u){return s(g(t,u))}f.md5=function(u,v,t){if(!v){if(!t){return k(u)}else{return p(u)}}if(!t){return q(v,u)}else{return g(v,u)}}}(typeof jQuery==="function"?jQuery:this)); 2 | jQuery(document).ready(function ($) { 3 | //居中 4 | $(window).resize(function () { 5 | $('.mycenter').css({ 6 | position: 'fixed', 7 | left: ($(window).width() - $('.mycenter').outerWidth()) / 2, 8 | top: ($(window).height() - $('.mycenter').outerHeight()) * 0.3 + $(document).scrollTop() 9 | }); 10 | }); 11 | $(window).resize(); 12 | 13 | 14 | //登录 15 | $('#login-form').submit(function (e) { 16 | var u = $('#username'); 17 | var p = $("#passwordPlain"); 18 | var tip = $('#tip'); 19 | var b = $('#login-form-submit'); 20 | $.ajax({ 21 | type: 'POST', 22 | url: 'login.do', 23 | data: { 24 | 'username': u.val(), 25 | 'password': $.md5("Orange" + u.val() + p.val()) 26 | }, 27 | dataType: 'json', 28 | beforeSend: function () { 29 | tip.html(' '); 30 | if (u.val() == '' || p.val() == '') { 31 | tip.html('用户名或密码不能为空'); 32 | return false; 33 | } 34 | b.attr('disabled',true); 35 | b.val('正在登录,请稍后'); 36 | }, 37 | success: function (r) { 38 | //console.log(r); 39 | if (r.ok == 'true') { 40 | window.location.href = r.msg; 41 | } else { 42 | tip.html(r.msg); 43 | } 44 | }, 45 | error: function () { 46 | $('#tip').html('网络错误'); 47 | }, 48 | complete:function(){ 49 | b.removeAttr('disabled'); 50 | b.val('登录'); 51 | } 52 | }); 53 | //https://www.ibm.com/developerworks/cn/web/wa-aj-authenticate/ 54 | //为了避免提交表单时刷新页面,您必须使用 preventDefault 函数。 55 | //要访问 preventDefault 函数,您必须传递处理函数(即使作为一个参数)或者使用它访问该函数。 56 | return e.preventDefault(); 57 | }); 58 | 59 | 60 | $("#add-admin").submit(function () { 61 | var v = $.md5("Orange" + $("#uname").val() + $("#passwdPlain").val()); 62 | $("#passwd").val(v); 63 | return true; 64 | }); 65 | 66 | 67 | }); 68 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/teacher/ScoreServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.teacher; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.ResultSet; 16 | import java.sql.SQLException; 17 | 18 | /** 19 | * Created by lin on 2016-02-22-022. 20 | */ 21 | @WebServlet(name = "ScoreServlet", value = "/teacher/score.do") 22 | public class ScoreServlet extends HttpServlet { 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 24 | HttpSession session = request.getSession(); 25 | //鉴权 26 | String logined = (String) session.getAttribute("logined"); 27 | Integer type = (Integer) session.getAttribute("type"); 28 | response.setContentType("application/json;charset=UTF-8"); 29 | PrintWriter out = response.getWriter(); 30 | if (logined == null || type == null || type != 2) { 31 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 32 | return; 33 | } 34 | String id = request.getParameter("id"), 35 | score = request.getParameter("score"); 36 | if (id == null || score == null) { 37 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 38 | return; 39 | } 40 | String s_id = id.substring(0, id.indexOf('-')), 41 | c_id = id.substring(id.indexOf('-') + 1); 42 | //System.out.println(s_id + " " + c_id); 43 | String point = "0", creadit = "0"; 44 | boolean passed = true; 45 | switch (score) { 46 | case "优秀": 47 | case "A": 48 | case "优": 49 | point = "4"; 50 | break; 51 | case "B": 52 | case "良好": 53 | case "良": 54 | point = "3"; 55 | break; 56 | case "C": 57 | case "中等": 58 | case "中": 59 | point = "2"; 60 | break; 61 | case "D": 62 | case "差": 63 | case "及格": 64 | point = "1"; 65 | break; 66 | case "E": 67 | case "不及格": 68 | point = "0"; 69 | passed = false; 70 | break; 71 | default: 72 | int s; 73 | try { 74 | s = Integer.parseInt(score); 75 | } catch (Exception e) { 76 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误(分数只能是0-100的数字或‘ABSDE’或优良中差不及格)\"}"); 77 | return; 78 | } 79 | if (s >= 0 && s < 60) { 80 | point = "0"; 81 | passed = false; 82 | } else if (s >= 60 && s < 65) { 83 | point = "1"; 84 | } else if (s >= 65 && s < 70) { 85 | point = "1.5"; 86 | } else if (s >= 70 && s < 75) { 87 | point = "2"; 88 | } else if (s >= 75 && s < 80) { 89 | point = "2.5"; 90 | } else if (s >= 80 && s < 85) { 91 | point = "3"; 92 | } else if (s >= 85 && s < 90) { 93 | point = "3.5"; 94 | } else if (s >= 90 && s <= 100) { 95 | point = "4"; 96 | } else { 97 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误(分数只能是0-100的数字或‘ABSDE’或优良中差不及格)\"}"); 98 | return; 99 | } 100 | } 101 | 102 | Connection con = JDBCUtil.getConnection(); 103 | String sql = "SELECT sec_creadits FROM sec WHERE c_id = ?"; 104 | if (passed) 105 | 106 | { 107 | //region 取得课程的学分 108 | try { 109 | PreparedStatement preparedStatement = con.prepareStatement(sql); 110 | preparedStatement.setString(1, c_id); 111 | ResultSet rs = preparedStatement.executeQuery(); 112 | while (rs.next()) { 113 | creadit = rs.getString("sec_creadits"); 114 | //System.out.println(creadit); 115 | } 116 | rs.close(); 117 | preparedStatement.close(); 118 | } catch (SQLException e) { 119 | e.printStackTrace(); 120 | }//endregion 121 | } 122 | 123 | sql = "UPDATE takes SET tk_score = ? , tk_point = ? , tk_credit = ? WHERE s_id = ? AND c_id = ?"; 124 | try 125 | 126 | { 127 | PreparedStatement pstmt = con.prepareStatement(sql); 128 | pstmt.setString(1, score); 129 | pstmt.setString(2, point); 130 | pstmt.setString(3, creadit); 131 | pstmt.setString(4, s_id); 132 | pstmt.setString(5, c_id); 133 | int i = pstmt.executeUpdate(); 134 | if (i > 0) { 135 | System.out.println("修改成绩成功"); 136 | out.println("{\"ok\":\"true\",\"msg\":\"成绩修改成功\"}"); 137 | } else { 138 | out.println("{\"ok\":\"false\",\"msg\":\"操作失败\"}"); 139 | } 140 | } catch ( 141 | SQLException e 142 | ) 143 | 144 | { 145 | e.printStackTrace(); 146 | out.println("{\"ok\":\"false\",\"msg\":\"操作失败(" + JDBCUtil.jsonReplace(e.getMessage()) + ")\"}"); 147 | } 148 | 149 | } 150 | 151 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 152 | 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin/AdminServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.net.ConnectException; 14 | import java.sql.Connection; 15 | import java.sql.PreparedStatement; 16 | import java.sql.SQLException; 17 | 18 | /** 19 | * Created by lin on 2016-01-11-011. 20 | */ 21 | @WebServlet(name = "AdminServlet", value = "/admin/admin2.do") 22 | public class AdminServlet extends HttpServlet { 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 24 | HttpSession session = request.getSession(); 25 | response.setContentType("application/json;charset=UTF-8"); 26 | PrintWriter out = response.getWriter(); 27 | 28 | //鉴权 29 | String logined = (String) session.getAttribute("logined"); 30 | Integer type = (Integer) session.getAttribute("type"); 31 | if (logined == null || type == null || type != 0) { 32 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 33 | return; 34 | } 35 | 36 | String target = request.getParameter("type"); 37 | if (target == null) { 38 | out.println("{\"ok\":\"false\",\"msg\":\"非法请求\"}"); 39 | return; 40 | } 41 | //添加用户 42 | switch (target) { 43 | case "add": { 44 | String name = request.getParameter("uname"); 45 | String passwd = request.getParameter("password"); 46 | String dept = request.getParameter("dept"); 47 | if (name == null || passwd == null || dept == null || passwd.length() != 32 48 | || name.equals("") || passwd.equals("") || dept.equals("")) { 49 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 50 | return; 51 | } 52 | if (name.toLowerCase().charAt(0) < 'a' || name.toLowerCase().charAt(0) > 'z') { 53 | out.println("{\"ok\":\"false\",\"msg\":\"用户名必须以字母开头\"}"); 54 | return; 55 | } 56 | Connection con = JDBCUtil.getConnection(); 57 | String sql = " INSERT INTO admin(id,name,passwd,type,d_name) " + 58 | " values(admin_id_sequence.nextval,?,?,1,?) "; 59 | try { 60 | PreparedStatement pstmt = con.prepareStatement(sql); 61 | pstmt.setString(1, name); 62 | pstmt.setString(2, passwd); 63 | pstmt.setString(3, dept); 64 | int i = pstmt.executeUpdate(); 65 | System.out.println("添加用户成功:" + i + "行受影响"); 66 | out.println("{\"ok\":\"true\",\"msg\":\"添加用户成功\"}"); 67 | } catch (SQLException e) { 68 | //e.printStackTrace(); 69 | out.println("{\"ok\":\"false\"," + 70 | "\"msg\":\"添加失败(用户名不能重复):[" + jsonReplace(e.getMessage()) + "]\"}"); 71 | } 72 | break; 73 | } 74 | //修改密码 75 | case "change": { 76 | String name = request.getParameter("username"); 77 | String newpasswd = request.getParameter("newpasswd"); 78 | if (name == null || newpasswd == null || name.equals("") || newpasswd.equals("")) { 79 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 80 | return; 81 | } 82 | //{"ok":"false","msg":"..."} 83 | String sql = "UPDATE admin SET passwd =? WHERE name = ?"; 84 | Connection con = JDBCUtil.getConnection(); 85 | try { 86 | PreparedStatement pstmt = con.prepareStatement(sql); 87 | pstmt.setString(1, newpasswd); 88 | pstmt.setString(2, name); 89 | int i = pstmt.executeUpdate(); 90 | System.out.println("修改密码成功:" + i + "行受影响"); 91 | out.println("{\"ok\":\"true\",\"msg\":\"修改密码成功\"}"); 92 | return; 93 | } catch (SQLException e) { 94 | // e.printStackTrace(); 95 | out.println("{\"ok\":\"false\"," + 96 | "\"msg\":\"修改密码失败[" + jsonReplace(e.getMessage()) + "]\"}"); 97 | return; 98 | } 99 | } 100 | default: 101 | out.println("{\"ok\":\"false\",\"msg\":\"参数不正确\"}"); 102 | break; 103 | } 104 | } 105 | 106 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 107 | HttpSession session = request.getSession(); 108 | response.setContentType("application/json;charset=UTF-8"); 109 | PrintWriter out = response.getWriter(); 110 | 111 | //鉴权 112 | String logined = (String) session.getAttribute("logined"); 113 | Integer type = (Integer) session.getAttribute("type"); 114 | if (logined == null || type == null || type != 0) { 115 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 116 | return; 117 | } 118 | 119 | String name = request.getParameter("name"); 120 | if (name == null || name.equals("")) { 121 | out.println("{\"ok\":\"false\",\"msg\":\"缺少参数\"}"); 122 | return; 123 | } 124 | Connection con = JDBCUtil.getConnection(); 125 | String sql = "DELETE FROM admin WHERE name = ?"; 126 | try { 127 | PreparedStatement pstmt = con.prepareStatement(sql); 128 | pstmt.setString(1, name); 129 | int i = pstmt.executeUpdate(); 130 | System.out.println("删除用户成功:" + i + "行受影响"); 131 | out.println("{\"ok\":\"true\",\"msg\":\"删除用户成功\"}"); 132 | return; 133 | } catch (SQLException e) { 134 | out.println("{\"ok\":\"false\",\"msg\":\"删除失败:[" + jsonReplace(e.getMessage()) + "]\"}"); 135 | return; 136 | } 137 | } 138 | 139 | private String jsonReplace(String str) { 140 | return str.replace("\"", "\'").replace(":", "_").replace("\n", " "); 141 | } 142 | 143 | } 144 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/LoginCheckServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.ResultSet; 16 | import java.sql.SQLException; 17 | 18 | /** 19 | * Created by lin on 2016-01-11-011. 20 | * 使用ajax post账号密码给此Servlet 21 | * 登录成功返回跳转地址,否则返回提示信息。 22 | */ 23 | @WebServlet(name = "LoginCheckServlet", urlPatterns = "/login.do") 24 | public class LoginCheckServlet extends HttpServlet { 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 26 | throws ServletException, IOException { 27 | HttpSession session = request.getSession(); 28 | response.setContentType("application/json;charset=UTF-8"); 29 | PrintWriter out = response.getWriter(); 30 | String result = ""; 31 | 32 | //有post数据 33 | if (request.getParameter("username") != null && request.getParameter("password") != null) { 34 | String username = request.getParameter("username"); 35 | String password = request.getParameter("password"); 36 | 37 | if (username == null || password == null || username.equals("") || password.length() != 32) { 38 | out.println("{\"ok\":\"false\",\"msg\":\"用户名或密码不能为空\"}"); 39 | return; 40 | } 41 | 42 | username = username.toLowerCase(); 43 | System.out.println("username=" + username + " password=" + password); 44 | 45 | Connection con = JDBCUtil.getConnection(); 46 | PreparedStatement pstmt = null; 47 | ResultSet rs = null; 48 | 49 | //管理员账号以字母开头 50 | if (username.charAt(0) >= 'a' && username.charAt(0) <= 'z') { 51 | String sql = "SELECT name,type,d_name FROM admin WHERE name = ? AND passwd = ?"; 52 | 53 | try { 54 | pstmt = con.prepareStatement(sql); 55 | pstmt.setString(1, username); 56 | pstmt.setString(2, password); 57 | rs = pstmt.executeQuery(); 58 | while (rs.next()) { 59 | //id:int name:varchar passwd:char type:int 60 | System.out.println("name:" + rs.getString(1) + " type:" + rs.getInt(2)); 61 | if (rs.getInt(2) == 0) { 62 | //把 账号名,账号类型 写入会话 63 | session.setAttribute("logined", rs.getString(1)); 64 | session.setAttribute("type", 0); 65 | System.out.println("管理员登录成功"); 66 | //response.sendRedirect("admin/"); 67 | out.println("{\"ok\":\"true\",\"msg\":\"admin/\"}"); 68 | return; 69 | } 70 | if (rs.getInt(2) == 1) { 71 | session.setAttribute("logined", rs.getString(1)); 72 | session.setAttribute("type", 1); 73 | session.setAttribute("dept", rs.getString("d_name")); 74 | System.out.println("教务登录成功"); 75 | //response.sendRedirect("admin2/"); 76 | out.println("{\"ok\":\"true\",\"msg\":\"admin2/\"}"); 77 | return; 78 | } 79 | }//while 80 | } catch (Exception e) { 81 | e.printStackTrace(); 82 | //session.setAttribute("msg", "数据库出错"); 83 | //response.sendRedirect(referer); 84 | out.println("{\"ok\":\"false\",\"msg\":\"数据库出错\"}"); 85 | return; 86 | } 87 | System.out.println("管理员尝试登录失败"); 88 | 89 | } else { 90 | //教师、学生 账号不是以字母开头 91 | String sql = "SELECT * FROM student WHERE s_id = ? AND s_passwd = ?"; 92 | try { 93 | pstmt = con.prepareStatement(sql); 94 | pstmt.setString(1, username); 95 | pstmt.setString(2, password); 96 | rs = pstmt.executeQuery(); 97 | while (rs.next()) { 98 | session.setAttribute("logined", rs.getString("s_name")); 99 | session.setAttribute("userId", rs.getString("s_id")); 100 | session.setAttribute("type", 3); 101 | session.setAttribute("dept", rs.getString("d_name")); 102 | System.out.println("学生登录"); 103 | //response.sendRedirect("user/"); 104 | out.println("{\"ok\":\"true\",\"msg\":\"user/\"}"); 105 | return; 106 | } 107 | 108 | sql = "SELECT * FROM teacher WHERE t_id = ? AND t_passwd = ?"; 109 | pstmt = con.prepareStatement(sql); 110 | pstmt.setString(1, username); 111 | pstmt.setString(2, password); 112 | rs = pstmt.executeQuery(); 113 | while (rs.next()) { 114 | session.setAttribute("logined", rs.getString("t_name")); 115 | session.setAttribute("userId", rs.getString("t_id")); 116 | session.setAttribute("type", 2); 117 | session.setAttribute("dept", rs.getString("d_name")); 118 | System.out.println("教师登录"); 119 | //response.sendRedirect("teacher/"); 120 | out.println("{\"ok\":\"true\",\"msg\":\"teacher/\"}"); 121 | return; 122 | } 123 | } catch (SQLException e) { 124 | e.printStackTrace(); 125 | //session.setAttribute("msg", "数据库出错"); 126 | out.println("{\"ok\":\"false\",\"msg\":\"数据库出错\"}"); 127 | } 128 | System.out.println("登录失败"); 129 | }//学生、教师账号不是字母开头 130 | 131 | }//有post数据 132 | 133 | //session.setAttribute("msg", "用户名或密码错误"); 134 | session.setAttribute("logined", null); 135 | //response.sendRedirect("login.jsp?reason=loginfailed"); 136 | out.println("{\"ok\":\"false\",\"msg\":\"用户名或密码错误\"}"); 137 | } 138 | 139 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 140 | response.sendRedirect("login.jsp?reason=login"); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /src/cn/edu/jlu/orange/servlet/admin2/AllStuServlet.java: -------------------------------------------------------------------------------- 1 | package cn.edu.jlu.orange.servlet.admin2; 2 | 3 | import cn.edu.jlu.orange.JDBCUtil; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.sql.Connection; 14 | import java.sql.PreparedStatement; 15 | import java.sql.SQLException; 16 | 17 | /** 18 | * Created by lin on 2016-01-25-025. 19 | */ 20 | @WebServlet(name = "AllStuServlet", value = "/admin2/stu.do") 21 | public class AllStuServlet extends HttpServlet { 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | HttpSession session = request.getSession(); 24 | response.setContentType("text/html;charset=UTF-8"); 25 | PrintWriter out = response.getWriter(); 26 | request.setCharacterEncoding("utf-8"); 27 | //鉴权 28 | String logined = (String) session.getAttribute("logined"); 29 | Integer types = (Integer) session.getAttribute("type"); 30 | if (logined == null || types == null || types != 1) { 31 | out.println("{\"ok\":\"false\",\"msg\":\"权限不足\"}"); 32 | return; 33 | } 34 | String type = request.getParameter("type"); 35 | String sql = ""; 36 | Connection con = null; 37 | switch (type) { 38 | //region //编辑 39 | case "edit": 40 | String id = request.getParameter("edit-stu-id"); 41 | String id2 = request.getParameter("edit-stu-id2"); 42 | String name = request.getParameter("edit-stu-name"); 43 | String gender = request.getParameter("edit-stu-gender"); 44 | String grade = request.getParameter("edit-stu-grade"); 45 | if (id == null || id2 == null || name == null || gender == null || grade == null 46 | || (!gender.equals("M") & !gender.equals("F")) 47 | || grade.trim().length() != 4) { 48 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误\"}"); 49 | return; 50 | } 51 | sql = "UPDATE student set s_id2 = ? , s_name = ? , s_gender = ? , s_grade = ? WHERE s_id = ?"; 52 | con = JDBCUtil.getConnection(); 53 | try { 54 | PreparedStatement pstmt = con.prepareStatement(sql); 55 | pstmt.setString(1, id2); 56 | pstmt.setString(2, name); 57 | pstmt.setString(3, gender); 58 | pstmt.setString(4, grade); 59 | pstmt.setString(5, id); 60 | // System.out.println(id + " " + id2 + " " + name + " " + gender + " " + grade); 61 | int i = pstmt.executeUpdate(); 62 | if (i > 0) { 63 | out.println("{\"ok\":\"true\",\"msg\":\"修改成功\"}"); 64 | return; 65 | } else { 66 | out.println("{\"ok\":\"false\",\"msg\":\"修改失败\"}"); 67 | return; 68 | } 69 | } catch (SQLException e) { 70 | // e.printStackTrace(); 71 | out.println("{\"ok\":\"false\"," + 72 | "\"msg\":\"执行修改操作失败:(" + JDBCUtil.jsonReplace(e.getMessage()) + ")\"}"); 73 | return; 74 | }//endregion 75 | // region //重置 76 | case "reset": { 77 | String list[] = request.getParameterValues("check-list"); 78 | if (list == null) { 79 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误(请至少选中一项)\"}"); 80 | return; 81 | } 82 | sql = "UPDATE student SET s_passwd = ? WHERE s_id = ?"; 83 | con = JDBCUtil.getConnection(); 84 | try { 85 | PreparedStatement pstmt = con.prepareStatement(sql); 86 | int i = 0; 87 | for (String item : list) { 88 | pstmt.setString(1, JDBCUtil.MD5("Orange" + item + item)); 89 | pstmt.setString(2, item); 90 | i += pstmt.executeUpdate(); 91 | } 92 | if (i > 0) { 93 | System.out.println("reset s_passwd:" + i + " row"); 94 | out.println("{\"ok\":\"true\",\"msg\":\"重置成功!(" + i + "条记录已修改)\"}"); 95 | return; 96 | } 97 | } catch (SQLException e) { 98 | // e.printStackTrace(); 99 | out.println("{\"ok\":\"false\"," + 100 | "\"msg\":\"执行数据库语句出错:[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 101 | return; 102 | } 103 | break; 104 | }//endregion 105 | //region //删除 106 | case "delete": { 107 | String list[] = request.getParameterValues("check-list"); 108 | if (list == null) { 109 | out.println("{\"ok\":\"false\",\"msg\":\"参数错误(请至少选中一项)\"}"); 110 | return; 111 | } 112 | sql = "DELETE FROM student WHERE s_id = ?"; 113 | con = JDBCUtil.getConnection(); 114 | try { 115 | PreparedStatement pstmt = con.prepareStatement(sql); 116 | int i = 0; 117 | for (String item : list) { 118 | pstmt.setString(1, item); 119 | i += pstmt.executeUpdate(); 120 | } 121 | if (i > 0) { 122 | System.out.println("Delete stu: " + i + " item(s)"); 123 | out.println("{\"ok\":\"true\",\"msg\":\"删除成功 (" + i + "条记录已删除)\"}"); 124 | return; 125 | } 126 | } catch (SQLException e) { 127 | // e.printStackTrace(); 128 | out.println("{\"ok\":\"false\"," + 129 | "\"msg\":\"执行删除操作失败(请刷新重试):[" + JDBCUtil.jsonReplace(e.getMessage()) + "]\"}"); 130 | return; 131 | } 132 | break; 133 | }//endregion 134 | } 135 | out.println("{\"ok\":\"false\",\"msg\":\"非法请求\"}"); 136 | return; 137 | } 138 | 139 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 140 | 141 | } 142 | } 143 | /* 144 | DEPARTMENT 145 | STUDENT 146 | TEACHER 147 | TIMESLOT 148 | CLASSROOM 149 | PLACETIME 150 | COURSE 151 | SEC 152 | TAKES 153 | TEACHES 154 | ADMIN 155 | NOTICE 156 | 157 | */ 158 | -------------------------------------------------------------------------------- /web/WEB-INF/content/admin/view-admin2.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: lin 4 | Date: 2015-12-17-017 5 | Time: 12:03 下午 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page import="cn.edu.jlu.orange.JDBCUtil" %> 9 | <%@ page import="java.sql.*" %> 10 | <%@ page trimDirectiveWhitespaces="true" %> 11 | <%@ page pageEncoding="UTF-8" language="java" %> 12 | 13 |
14 |

添加教务用户

15 |

用户名不能与已有用户名重复,且只能以字母开头。

16 | <%//alter table admin add constraint uq_admin_name unique(name);%> 17 | 21 |
22 | 23 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 49 |
50 | 51 | 52 |

 

53 |
54 | 55 |
56 |

教务用户一览

57 | 58 | 59 | 60 | 62 | 63 | 64 | 67 | 70 | 71 | 72 | 73 | <% 74 | sql = "SELECT id,name,type,d_name FROM admin WHERE type = 1 ORDER BY type,id"; 75 | Statement stmt = con.createStatement(); 76 | rs = stmt.executeQuery(sql); 77 | int i = 0; 78 | boolean hasresult = false; 79 | while (rs.next()) { 80 | hasresult = true; 81 | %> 82 | 83 | 84 | 86 | 88 | 94 | 100 | 101 | <% 102 | } 103 | %> 104 | 105 |
序号 61 | 用户名所属 65 | 修改密码 66 | 68 | 删除 69 |
"><%=++i%><%=rs.getString("name")%> 85 | <%=rs.getString("d_name")%> 87 | 89 | 93 | 95 | 99 |
106 |
107 | <% 108 | if (hasresult) { 109 | %> 110 | 142 | 143 | 176 | 177 | <% 178 | } 179 | %> 180 | --------------------------------------------------------------------------------