当前位置:   article > 正文

一个简单的javaweb小项目(适合新手上手)_javaweb项目案例

javaweb项目案例

案例说明:学习完javaweb的所有技术栈后用来上手的小项目有,用到的技术栈有jsp+JDBC+servlet,使用的工具是idea2022版+tomcat8.0.53

gitee 地址:MSTU3: 一个简单的入门小项目 (gitee.com)

目录

 项目功能演示: 

1.登录

2.首页

3.人员管理(在此界面可以进行人员信息的修改)

4.任务管理(此界面可以进行任务的修改删除)​编辑

5.我的信息​编辑

6.退出系统,返回登录界面​编辑

项目代码:

bean包

数据交互层(此处省略了接口):

数据库连接工具:

业务逻辑层(此处省略了接口):

数据库连接信息:

静态页面(其中用到的一些图片需要自己提供):


 项目功能演示:

1.登录

2.首页

3.人员管理(在此界面可以进行人员信息的修改)

4.任务管理(此界面可以进行任务的修改删除)

5.我的信息

6.退出系统,返回登录界面

项目代码:

bean包

  1. package com.bean;
  2. /**
  3. * @BelongsProject: MSTU1
  4. * @BelongsPackage: com.bean
  5. * @FileName: Person
  6. * @Author: 峰。
  7. * @Date: 2023/8/21-19:47
  8. * @Version: 1.0
  9. * @Description:
  10. */
  11. public class Person {
  12. private String userAccount;
  13. private int userIdentify;
  14. private String userName;
  15. private String userSex;
  16. private String userBirthday;
  17. private String userIdCard;
  18. private String userPassword;
  19. private String userOtherName;
  20. public Person() {
  21. }
  22. public Person(String userAccount, String userPassword) {
  23. this.userAccount = userAccount;
  24. this.userPassword = userPassword;
  25. }
  26. @Override
  27. public String toString() {
  28. return "Person{" +
  29. "userAccount='" + userAccount + '\'' +
  30. ", userIdentify=" + userIdentify +
  31. ", userName='" + userName + '\'' +
  32. ", userSex='" + userSex + '\'' +
  33. ", userBirthday='" + userBirthday + '\'' +
  34. ", userIdCard='" + userIdCard + '\'' +
  35. ", userPassword='" + userPassword + '\'' +
  36. ", userOtherName='" + userOtherName + '\'' +
  37. '}';
  38. }
  39. public Person(String userAccount, int userIdentify, String userName, String userSex, String userBirthday, String userIdCard, String userPassword, String userOtherName) {
  40. this.userAccount = userAccount;
  41. this.userIdentify = userIdentify;
  42. this.userName = userName;
  43. this.userSex = userSex;
  44. this.userBirthday = userBirthday;
  45. this.userIdCard = userIdCard;
  46. this.userPassword = userPassword;
  47. this.userOtherName = userOtherName;
  48. }
  49. public String getUserAccount() {
  50. return userAccount;
  51. }
  52. public void setUserAccount(String userAccount) {
  53. this.userAccount = userAccount;
  54. }
  55. public int getUserIdentify() {
  56. return userIdentify;
  57. }
  58. public void setUserIdentify(int userIdentify) {
  59. this.userIdentify = userIdentify;
  60. }
  61. public String getUserName() {
  62. return userName;
  63. }
  64. public void setUserName(String userName) {
  65. this.userName = userName;
  66. }
  67. public String getUserSex() {
  68. return userSex;
  69. }
  70. public void setUserSex(String userSex) {
  71. this.userSex = userSex;
  72. }
  73. public String getUserBirthday() {
  74. return userBirthday;
  75. }
  76. public void setUserBirthday(String userBirthday) {
  77. this.userBirthday = userBirthday;
  78. }
  79. public String getUserIdCard() {
  80. return userIdCard;
  81. }
  82. public void setUserIdCard(String userIdCard) {
  83. this.userIdCard = userIdCard;
  84. }
  85. public String getUserPassword() {
  86. return userPassword;
  87. }
  88. public void setUserPassword(String userPassword) {
  89. this.userPassword = userPassword;
  90. }
  91. public String getUserOtherName() {
  92. return userOtherName;
  93. }
  94. public void setUserOtherName(String userOtherName) {
  95. this.userOtherName = userOtherName;
  96. }
  97. }
  1. package com.bean;
  2. /**
  3. * @BelongsProject: MUST3
  4. * @BelongsPackage: com.bean
  5. * @FileName: studentTask
  6. * @Author: 峰。
  7. * @Date: 2023/8/23-17:11
  8. * @Version: 1.0
  9. * @Description:
  10. */
  11. public class studentTask {
  12. private String taskAccount;
  13. private String studentAccount;
  14. private String studentAnswer;
  15. private int isFinish;
  16. private int Score;
  17. private String StudentName;
  18. public studentTask() {
  19. }
  20. public studentTask(String taskAccount, String studentAccount, String studentAnswer, int isFinish, int score,String S) {
  21. this.taskAccount = taskAccount;
  22. this.studentAccount = studentAccount;
  23. this.studentAnswer = studentAnswer;
  24. this.isFinish = isFinish;
  25. Score = score;
  26. this.StudentName=S;
  27. }
  28. public String getStudentName() {
  29. return StudentName;
  30. }
  31. public void setStudentName(String studentName) {
  32. StudentName = studentName;
  33. }
  34. public String getTaskAccount() {
  35. return taskAccount;
  36. }
  37. public void setTaskAccount(String taskAccount) {
  38. this.taskAccount = taskAccount;
  39. }
  40. public String getStudentAccount() {
  41. return studentAccount;
  42. }
  43. public void setStudentAccount(String studentAccount) {
  44. this.studentAccount = studentAccount;
  45. }
  46. public String getStudentAnswer() {
  47. return studentAnswer;
  48. }
  49. public void setStudentAnswer(String studentAnswer) {
  50. this.studentAnswer = studentAnswer;
  51. }
  52. public int getIsFinish() {
  53. return this.isFinish;
  54. }
  55. public void setIsFinish(int isFinish) {
  56. this.isFinish = isFinish;
  57. }
  58. public int getScore() {
  59. return Score;
  60. }
  61. public void setScore(int score) {
  62. Score = score;
  63. }
  64. @Override
  65. public String toString() {
  66. return "studentTask{" +
  67. "taskAccount='" + taskAccount + '\'' +
  68. ", studentAccount='" + studentAccount + '\'' +
  69. ", studentAnswer='" + studentAnswer + '\'' +
  70. ", isFinish=" + isFinish +
  71. ", Score=" + Score +
  72. '}';
  73. }
  74. }
  1. package com.bean;
  2. /**
  3. * @BelongsProject: MUST3
  4. * @BelongsPackage: com.bean
  5. * @FileName: task
  6. * @Author: 峰。
  7. * @Date: 2023/8/23-15:16
  8. * @Version: 1.0
  9. * @Description:
  10. */
  11. public class task {
  12. private String task;
  13. private String teacherAccount;
  14. private String taskDate;
  15. private String taskName;
  16. public task() {
  17. }
  18. public task(String task, String teacherAccount, String taskDate, String taskName) {
  19. this.task = task;
  20. this.teacherAccount = teacherAccount;
  21. this.taskDate = taskDate;
  22. this.taskName = taskName;
  23. }
  24. @Override
  25. public String toString() {
  26. return "task{" +
  27. "task='" + task + '\'' +
  28. ", teacherAccount='" + teacherAccount + '\'' +
  29. ", taskDate='" + taskDate + '\'' +
  30. ", taskName='" + taskName + '\'' +
  31. '}';
  32. }
  33. public String getTask() {
  34. return task;
  35. }
  36. public void setTask(String task) {
  37. this.task = task;
  38. }
  39. public String getTeacherAccount() {
  40. return teacherAccount;
  41. }
  42. public void setTeacherAccount(String teacherAccount) {
  43. this.teacherAccount = teacherAccount;
  44. }
  45. public String getTaskDate() {
  46. return taskDate;
  47. }
  48. public void setTaskDate(String taskDate) {
  49. this.taskDate = taskDate;
  50. }
  51. public String getTaskName() {
  52. return taskName;
  53. }
  54. public void setTaskName(String taskName) {
  55. this.taskName = taskName;
  56. }
  57. }

数据交互层(此处省略了接口):

  1. package com.Dao;
  2. import com.DBUtiles.DBUtils;
  3. import com.bean.Person;
  4. import com.bean.studentTask;
  5. import com.bean.task;
  6. import java.sql.Connection;
  7. import java.sql.PreparedStatement;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. /**
  13. * @BelongsProject: MUST3
  14. * @BelongsPackage: com.Dao
  15. * @FileName: commonDaoImpl
  16. * @Author: 峰。
  17. * @Date: 2023/8/26-14:33
  18. * @Version: 1.0
  19. * @Description:
  20. */
  21. public class commonDaoImpl implements commonDao{
  22. @Override
  23. public void deletePerson(String sql) {
  24. Connection connection = null;
  25. PreparedStatement preparedStatement = null;
  26. ResultSet resultSet = null;
  27. int res = 0;
  28. List<studentTask> personLsit = new ArrayList<>();
  29. try {
  30. connection = DBUtils.getConnection();
  31. preparedStatement = connection.prepareStatement(sql);
  32. res = preparedStatement.executeUpdate();
  33. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  34. } catch (ClassNotFoundException e) {
  35. throw new RuntimeException(e);
  36. } catch (SQLException e) {
  37. throw new RuntimeException(e);
  38. }
  39. }
  40. @Override
  41. public List<Person> getAllTea(String sql) {
  42. Connection connection = null;
  43. PreparedStatement preparedStatement = null;
  44. ResultSet resultSet = null;
  45. List<Person> personLsit = new ArrayList<>();
  46. try {
  47. connection = DBUtils.getConnection();
  48. preparedStatement = connection.prepareStatement(sql);
  49. resultSet = preparedStatement.executeQuery();
  50. while(resultSet.next()){
  51. Person person = new Person();
  52. person.setUserName(resultSet.getString("userName"));
  53. person.setUserSex(resultSet.getString("userSex"));
  54. person.setUserIdCard(resultSet.getString("userIdCard"));
  55. person.setUserOtherName(resultSet.getString("userOtherName"));
  56. person.setUserIdentify(resultSet.getInt("userIdentify"));
  57. person.setUserAccount(resultSet.getString("userAccount"));
  58. person.setUserPassword(resultSet.getString("userPassword"));
  59. person.setUserBirthday(resultSet.getString("userBirthday"));
  60. personLsit.add(person);
  61. }
  62. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  63. } catch (ClassNotFoundException e) {
  64. throw new RuntimeException(e);
  65. } catch (SQLException e) {
  66. throw new RuntimeException(e);
  67. }
  68. return personLsit;
  69. }
  70. @Override
  71. public void selectTea(String sql) {
  72. Connection connection = null;
  73. PreparedStatement preparedStatement = null;
  74. ResultSet resultSet = null;
  75. int res = 0;
  76. try {
  77. connection = DBUtils.getConnection();
  78. preparedStatement = connection.prepareStatement(sql);
  79. res = preparedStatement.executeUpdate();
  80. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  81. } catch (ClassNotFoundException e) {
  82. throw new RuntimeException(e);
  83. } catch (SQLException e) {
  84. throw new RuntimeException(e);
  85. }
  86. }
  87. @Override
  88. public List<studentTask> getMyTask(String sql) {
  89. Connection connection = null;
  90. PreparedStatement preparedStatement = null;
  91. ResultSet resultSet = null;
  92. List<studentTask> personLsit = new ArrayList<>();
  93. try {
  94. connection = DBUtils.getConnection();
  95. preparedStatement = connection.prepareStatement(sql);
  96. resultSet = preparedStatement.executeQuery();
  97. while(resultSet.next()){
  98. studentTask st = new studentTask();
  99. st.setIsFinish(resultSet.getInt("isFinish"));
  100. st.setScore(resultSet.getInt("Score"));
  101. st.setStudentAccount(resultSet.getString("StudentAccount"));
  102. st.setTaskAccount(resultSet.getString("taskAccount"));
  103. st.setStudentName(resultSet.getString("userName"));
  104. st.setStudentAnswer(resultSet.getString("studentAnswer"));
  105. personLsit.add(st);
  106. }
  107. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  108. } catch (ClassNotFoundException e) {
  109. throw new RuntimeException(e);
  110. } catch (SQLException e) {
  111. throw new RuntimeException(e);
  112. }
  113. return personLsit;
  114. }
  115. }
  1. package com.Dao;
  2. import com.DBUtiles.DBUtils;
  3. import com.bean.Person;
  4. import com.bean.task;
  5. import java.sql.Connection;
  6. import java.sql.PreparedStatement;
  7. import java.sql.ResultSet;
  8. import java.sql.SQLException;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. /**
  12. * @BelongsProject: MUST3
  13. * @BelongsPackage: com.Dao
  14. * @FileName: ManageDaoImpl
  15. * @Author: 峰。
  16. * @Date: 2023/8/22-20:11
  17. * @Version: 1.0
  18. * @Description:
  19. */
  20. public class ManageDaoImpl implements ManageDao{
  21. @Override
  22. public List<Person> getAllPerson() {
  23. String sql = "select * from person where userIdentify != 2";
  24. return getAPerson(sql);
  25. }
  26. @Override
  27. public List<task> getAllTask(String sql) {
  28. Connection connection = null;
  29. PreparedStatement preparedStatement = null;
  30. ResultSet resultSet = null;
  31. List<task> personLsit = new ArrayList<>();
  32. try {
  33. connection = DBUtils.getConnection();
  34. preparedStatement = connection.prepareStatement(sql);
  35. resultSet = preparedStatement.executeQuery();
  36. while(resultSet.next()){
  37. task task = new task();
  38. task.setTask(resultSet.getString("taskAccount"));
  39. task.setTaskDate(resultSet.getString("taskDate"));
  40. task.setTaskName(resultSet.getString("taskName"));
  41. task.setTeacherAccount(resultSet.getString("teacherAccount"));
  42. personLsit.add(task);
  43. }
  44. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  45. } catch (ClassNotFoundException e) {
  46. throw new RuntimeException(e);
  47. } catch (SQLException e) {
  48. throw new RuntimeException(e);
  49. }
  50. return personLsit;
  51. }
  52. private List<Person> getAPerson(String sql) {
  53. Connection connection = null;
  54. PreparedStatement preparedStatement = null;
  55. ResultSet resultSet = null;
  56. List<Person> personLsit = new ArrayList<>();
  57. try {
  58. connection = DBUtils.getConnection();
  59. preparedStatement = connection.prepareStatement(sql);
  60. resultSet = preparedStatement.executeQuery();
  61. while(resultSet.next()){
  62. Person person = new Person();
  63. person.setUserName(resultSet.getString("userName"));
  64. person.setUserSex(resultSet.getString("userSex"));
  65. person.setUserIdCard(resultSet.getString("userIdCard"));
  66. person.setUserOtherName(resultSet.getString("userOtherName"));
  67. person.setUserIdentify(resultSet.getInt("userIdentify"));
  68. person.setUserAccount(resultSet.getString("userAccount"));
  69. person.setUserPassword(resultSet.getString("userPassword"));
  70. person.setUserBirthday(resultSet.getString("userBirthday"));
  71. personLsit.add(person);
  72. }
  73. } catch (ClassNotFoundException e) {
  74. throw new RuntimeException(e);
  75. } catch (SQLException e) {
  76. throw new RuntimeException(e);
  77. }
  78. return personLsit;
  79. }
  80. }
  1. package com.Dao;
  2. import com.DBUtiles.DBUtils;
  3. import com.bean.Person;
  4. import com.bean.studentTask;
  5. import java.sql.Connection;
  6. import java.sql.PreparedStatement;
  7. import java.sql.ResultSet;
  8. import java.sql.SQLException;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. /**
  12. * @BelongsProject: MUST3
  13. * @BelongsPackage: com.Dao
  14. * @FileName: registerDaoImpl
  15. * @Author: 峰。
  16. * @Date: 2023/8/24-18:16
  17. * @Version: 1.0
  18. * @Description:
  19. */
  20. public class registerDaoImpl implements registerDao {
  21. @Override
  22. public int addUser(String sql) {
  23. Connection connection = null;
  24. PreparedStatement preparedStatement = null;
  25. ResultSet resultSet = null;
  26. int res = 0;
  27. List<studentTask> personLsit = new ArrayList<>();
  28. try {
  29. connection = DBUtils.getConnection();
  30. preparedStatement = connection.prepareStatement(sql);
  31. res = preparedStatement.executeUpdate(sql);
  32. } catch (ClassNotFoundException e) {
  33. throw new RuntimeException(e);
  34. } catch (SQLException e) {
  35. throw new RuntimeException(e);
  36. }
  37. if (res == 1) {
  38. System.out.println("添加成功");
  39. return res;
  40. } else {
  41. System.out.println("添加失败");
  42. return res;
  43. }
  44. }
  45. }
  1. package com.Dao;
  2. import com.DBUtiles.DBUtils;
  3. import com.bean.Person;
  4. import com.bean.studentTask;
  5. import com.bean.task;
  6. import java.sql.Connection;
  7. import java.sql.PreparedStatement;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. /**
  13. * @BelongsProject: MUST3
  14. * @BelongsPackage: com.Dao
  15. * @FileName: StudentDaoImpl
  16. * @Author: 峰。
  17. * @Date: 2023/8/22-20:11
  18. * @Version: 1.0
  19. * @Description:
  20. */
  21. public class StudentDaoImpl implements StudentDao{
  22. @Override
  23. public List<Person> getStudentList(String sql) {
  24. Connection connection = null;
  25. PreparedStatement preparedStatement = null;
  26. ResultSet resultSet = null;
  27. List<Person> personLsit = new ArrayList<>();
  28. try {
  29. connection = DBUtils.getConnection();
  30. preparedStatement = connection.prepareStatement(sql);
  31. resultSet = preparedStatement.executeQuery();
  32. while(resultSet.next()){
  33. Person person = new Person();
  34. person.setUserName(resultSet.getString("userName"));
  35. person.setUserSex(resultSet.getString("userSex"));
  36. person.setUserIdCard(resultSet.getString("userIdCard"));
  37. person.setUserOtherName(resultSet.getString("userOtherName"));
  38. person.setUserIdentify(resultSet.getInt("userIdentify"));
  39. person.setUserAccount(resultSet.getString("userAccount"));
  40. person.setUserPassword(resultSet.getString("userPassword"));
  41. person.setUserBirthday(resultSet.getString("userBirthday"));
  42. personLsit.add(person);
  43. }
  44. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  45. } catch (ClassNotFoundException e) {
  46. throw new RuntimeException(e);
  47. } catch (SQLException e) {
  48. throw new RuntimeException(e);
  49. }
  50. return personLsit;
  51. }
  52. @Override
  53. public List<task> getAllMyTask(String sql) {
  54. Connection connection = null;
  55. PreparedStatement preparedStatement = null;
  56. ResultSet resultSet = null;
  57. List<task> personLsit = new ArrayList<>();
  58. try {
  59. connection = DBUtils.getConnection();
  60. preparedStatement = connection.prepareStatement(sql);
  61. resultSet = preparedStatement.executeQuery();
  62. while(resultSet.next()){
  63. task task = new task();
  64. task.setTask(resultSet.getString("taskAccount"));
  65. task.setTaskDate(resultSet.getString("taskDate"));
  66. task.setTaskName(resultSet.getString("taskName"));
  67. task.setTeacherAccount(resultSet.getString("teacherAccount"));
  68. personLsit.add(task);
  69. }
  70. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  71. } catch (ClassNotFoundException e) {
  72. throw new RuntimeException(e);
  73. } catch (SQLException e) {
  74. throw new RuntimeException(e);
  75. }
  76. return personLsit;
  77. }
  78. @Override
  79. public List<studentTask> getTaskDetail(String sql) {
  80. Connection connection = null;
  81. PreparedStatement preparedStatement = null;
  82. ResultSet resultSet = null;
  83. List<studentTask> personLsit = new ArrayList<>();
  84. try {
  85. connection = DBUtils.getConnection();
  86. preparedStatement = connection.prepareStatement(sql);
  87. resultSet = preparedStatement.executeQuery();
  88. while(resultSet.next()){
  89. studentTask st = new studentTask();
  90. st.setIsFinish(resultSet.getInt("isFinish"));
  91. st.setScore(resultSet.getInt("Score"));
  92. st.setStudentAccount(resultSet.getString("StudentAccount"));
  93. st.setTaskAccount(resultSet.getString("taskAccount"));
  94. st.setStudentName(resultSet.getString("userName"));
  95. st.setStudentAnswer(resultSet.getString("studentAnswer"));
  96. personLsit.add(st);
  97. }
  98. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  99. } catch (ClassNotFoundException e) {
  100. throw new RuntimeException(e);
  101. } catch (SQLException e) {
  102. throw new RuntimeException(e);
  103. }
  104. return personLsit;
  105. }
  106. @Override
  107. public int upScore(String sql) {
  108. Connection connection = null;
  109. PreparedStatement preparedStatement = null;
  110. ResultSet resultSet = null;
  111. int res = 0;
  112. List<studentTask> personLsit = new ArrayList<>();
  113. try {
  114. connection = DBUtils.getConnection();
  115. preparedStatement = connection.prepareStatement(sql);
  116. res = preparedStatement.executeUpdate();
  117. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  118. } catch (ClassNotFoundException e) {
  119. throw new RuntimeException(e);
  120. } catch (SQLException e) {
  121. throw new RuntimeException(e);
  122. }
  123. return res;
  124. }
  125. @Override
  126. public List<Person> getMySelf(String sql) {
  127. Connection connection = null;
  128. PreparedStatement preparedStatement = null;
  129. ResultSet resultSet = null;
  130. List<Person> personLsit = new ArrayList<>();
  131. try {
  132. connection = DBUtils.getConnection();
  133. preparedStatement = connection.prepareStatement(sql);
  134. resultSet = preparedStatement.executeQuery();
  135. while(resultSet.next()){
  136. Person person = new Person();
  137. person.setUserName(resultSet.getString("userName"));
  138. person.setUserSex(resultSet.getString("userSex"));
  139. person.setUserIdCard(resultSet.getString("userIdCard"));
  140. person.setUserOtherName(resultSet.getString("userOtherName"));
  141. person.setUserIdentify(resultSet.getInt("userIdentify"));
  142. person.setUserAccount(resultSet.getString("userAccount"));
  143. person.setUserPassword(resultSet.getString("userPassword"));
  144. person.setUserBirthday(resultSet.getString("userBirthday"));
  145. personLsit.add(person);
  146. }
  147. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  148. } catch (ClassNotFoundException e) {
  149. throw new RuntimeException(e);
  150. } catch (SQLException e) {
  151. throw new RuntimeException(e);
  152. }
  153. return personLsit;
  154. }
  155. @Override
  156. public void upAnswer(String sql) {
  157. upScore(sql);
  158. }
  159. @Override
  160. public List<studentTask> getStuTask(String sql) {
  161. Connection connection = null;
  162. PreparedStatement preparedStatement = null;
  163. ResultSet resultSet = null;
  164. List<studentTask> personLsit = new ArrayList<>();
  165. try {
  166. connection = DBUtils.getConnection();
  167. preparedStatement = connection.prepareStatement(sql);
  168. resultSet = preparedStatement.executeQuery();
  169. while(resultSet.next()){
  170. studentTask st = new studentTask();
  171. st.setIsFinish(resultSet.getInt("isFinish"));
  172. st.setScore(resultSet.getInt("Score"));
  173. st.setStudentAccount(resultSet.getString("StudentAccount"));
  174. st.setTaskAccount(resultSet.getString("taskAccount"));
  175. st.setStudentAnswer(resultSet.getString("studentAnswer"));
  176. personLsit.add(st);
  177. }
  178. DBUtils.ClearAll(connection,preparedStatement,resultSet);
  179. } catch (ClassNotFoundException e) {
  180. throw new RuntimeException(e);
  181. } catch (SQLException e) {
  182. throw new RuntimeException(e);
  183. }
  184. return personLsit;
  185. }
  186. }

数据库连接工具:

  1. package com.DBUtiles;
  2. import java.sql.*;
  3. /**
  4. * @BelongsProject: Tab8
  5. * @BelongsPackage: com.JDBCConnect.www
  6. * @FileName: DBUtils
  7. * @Author: 峰。
  8. * @Date: 2023/5/9-23:27
  9. * @Version: 1.0
  10. * @Description: JDBC工具类,两个方法,1)获取连接,2)释放资源
  11. */
  12. public class DBUtils {
  13. //1)建立连接
  14. public static Connection getConnection() throws ClassNotFoundException, SQLException {
  15. Class.forName("com.mysql.cj.jdbc.Driver");
  16. String url = "jdbc:mysql://localhost:3306/db_it1?useSSL=false";
  17. String user = "root";
  18. String password = "wbf";
  19. Connection connection = (Connection) DriverManager.getConnection(url, user, password);
  20. System.out.println("数据库连接成功~");
  21. return connection;
  22. }
  23. //2)释放资源
  24. public static void ClearAll(Connection connection, Statement statement, ResultSet resultSet) throws SQLException {
  25. //空值不能关闭 先开后关
  26. if (resultSet!=null){
  27. resultSet.close();
  28. }
  29. if (statement!=null){
  30. statement.close();
  31. }
  32. if (connection!=null){
  33. connection.close();
  34. }
  35. }
  36. }

业务逻辑层(此处省略了接口):

  1. package com.service;
  2. import com.Dao.commonDao;
  3. import com.Dao.commonDaoImpl;
  4. import com.bean.Person;
  5. import com.bean.studentTask;
  6. import com.bean.task;
  7. import java.util.List;
  8. /**
  9. * @BelongsProject: MUST3
  10. * @BelongsPackage: com.service
  11. * @FileName: commonServiceImpl
  12. * @Author: 峰。
  13. * @Date: 2023/8/26-14:33
  14. * @Version: 1.0
  15. * @Description:
  16. */
  17. public class commonServiceImpl implements commonService{
  18. commonDao cd = new commonDaoImpl();
  19. @Override
  20. public void deletePerson(String userAccount) {
  21. String sql = "delete from person where userAccount = '"+userAccount+"'";
  22. cd.deletePerson(sql);
  23. }
  24. @Override
  25. public List<Person> getAllTea() {
  26. String sql = "select * from person where userIdentify = 0";
  27. return cd.getAllTea(sql);
  28. }
  29. @Override
  30. public void selectPash(String userAccount, String Account) {
  31. String sql = "insert into userteacher(userAccount,teacherAccount) values('"+Account+"','"+userAccount+"')";
  32. cd.selectTea(sql);
  33. }
  34. @Override
  35. public List<studentTask> selectTaskDetail(String taskAccount) {
  36. String sql = "select * from studenttask where taskAccount = "+taskAccount+"";
  37. return cd.getMyTask(sql);
  38. }
  39. }
  1. package com.service;
  2. import com.Dao.ManageDao;
  3. import com.Dao.ManageDaoImpl;
  4. import com.bean.Person;
  5. import com.bean.task;
  6. import java.util.List;
  7. /**
  8. * @BelongsProject: MUST3
  9. * @BelongsPackage: com.service
  10. * @FileName: ManageServiceImpl
  11. * @Author: 峰。
  12. * @Date: 2023/8/22-20:04
  13. * @Version: 1.0
  14. * @Description:
  15. */
  16. public class ManageServiceImpl implements ManageService{
  17. ManageDao md = new ManageDaoImpl();
  18. @Override
  19. public List<Person> getAllPerson() {
  20. return md.getAllPerson();
  21. }
  22. @Override
  23. public List<task> getAllTask() {
  24. String sql = "select * from task";
  25. return md.getAllTask(sql);
  26. }
  27. }
  1. package com.service;
  2. import com.Dao.registerDao;
  3. import com.Dao.registerDaoImpl;
  4. import com.bean.Person;
  5. import java.util.Random;
  6. /**
  7. * @BelongsProject: MUST3
  8. * @BelongsPackage: com.service
  9. * @FileName: registerServiceImpl
  10. * @Author: 峰。
  11. * @Date: 2023/8/24-18:16
  12. * @Version: 1.0
  13. * @Description:
  14. */
  15. public class registerServiceImpl implements registerService{
  16. registerDao rd = new registerDaoImpl();
  17. @Override
  18. public int addUser(Person person) {
  19. person.setUserIdCard(RandomIdCard());
  20. String sql = "insert into person (userAccount,userBirthday,userIdCard,userIdentify,userName,userOtherName,userPassword,userSex) \n" +
  21. "values ('"+person.getUserAccount()+"','"+person.getUserBirthday()+"','"+person.getUserIdCard()+"'," +
  22. ""+person.getUserIdentify()+",'"+person.getUserName()+"','"+person.getUserOtherName()+"','"+person.getUserPassword()+"'" +
  23. ",'"+person.getUserSex()+"')";
  24. return rd.addUser(sql);
  25. }
  26. public String RandomIdCard(){
  27. Random random = new Random();
  28. String idcard = "";
  29. for (int i = 0 ;i<9;i++) {
  30. String randomNumber = String.valueOf(random.nextInt(10));
  31. System.out.println("随机数: " + randomNumber);
  32. idcard = idcard+randomNumber;
  33. }
  34. System.out.println(idcard);
  35. return idcard;
  36. }
  37. }
  1. package com.service;
  2. import com.Dao.StudentDao;
  3. import com.Dao.StudentDaoImpl;
  4. import com.bean.Person;
  5. import com.bean.studentTask;
  6. import com.bean.task;
  7. import java.util.List;
  8. /**
  9. * @BelongsProject: MUST3
  10. * @BelongsPackage: com.service
  11. * @FileName: StudentServiceImpl
  12. * @Author: 峰。
  13. * @Date: 2023/8/22-20:03
  14. * @Version: 1.0
  15. * @Description:
  16. */
  17. public class StudentServiceImpl implements StudentService{
  18. StudentDao sd = new StudentDaoImpl();
  19. @Override
  20. public List<Person> getAllStudent(String userAccount) {
  21. String sql = "select * from person where userAccount in (select userAccount from userteacher where teacherAccount = '"+userAccount+"')";
  22. return sd.getStudentList(sql);
  23. }
  24. @Override
  25. public List<task> getAllMyTask(String userAccount) {
  26. String sql = "select * from task where teacherAccount = '"+userAccount+"'";
  27. return sd.getAllMyTask(sql);
  28. }
  29. public List<studentTask> getAllStuTask(String userAccount) {
  30. String sql = "select * from studenttask where studentAccount = '"+userAccount+"'";
  31. return sd.getStuTask(sql);
  32. }
  33. @Override
  34. public List<studentTask> getTaskDetail(String taskAccount) {
  35. String sql = "select * from studenttask,person where studenttask.studentAccount=person.userAccount and taskAccount='"+taskAccount+"';";
  36. return sd.getTaskDetail(sql);
  37. }
  38. @Override
  39. public int upScore(int upScore, String taskAccount) {
  40. String sql = "update studenttask set Score = "+upScore+" where taskAccount = '"+taskAccount+"';";
  41. return sd.upScore(sql);
  42. }
  43. @Override
  44. public int DelTask(String taskAccount) {
  45. String sql = "delete from studenttask where taskAccount = '"+taskAccount+"'";
  46. String sql1 = "delete from task where taskAccount = '"+taskAccount+"'";
  47. sd.upScore(sql);
  48. sd.upScore(sql1);
  49. return 0;
  50. }
  51. @Override
  52. public void upName(String upName,String userName) {
  53. String sql = "update person set userName = '"+upName+"' where userAccount = '"+userName+"'";
  54. sd.upScore(sql);
  55. }
  56. @Override
  57. public void upSex(String upSex,String userName) {
  58. String sql = "update person set userSex = '"+upSex+"' where userAccount = '"+userName+"'";
  59. sd.upScore(sql);
  60. }
  61. @Override
  62. public void upBirthday(String upBirthday,String userName) {
  63. String sql = "update person set userBirthday = '"+upBirthday+"' where userAccount = '"+userName+"'";
  64. sd.upScore(sql);
  65. }
  66. @Override
  67. public void upOtherName(String upOtherName,String userName) {
  68. String sql = "update person set userOtherName = '"+upOtherName+"' where userAccount = '"+userName+"'";
  69. sd.upScore(sql);
  70. }
  71. @Override
  72. public List<Person> getMySelf(String userAccount) {
  73. String sql = "select * from person where userAccount = '"+userAccount+"'";
  74. return sd.getMySelf(sql);
  75. }
  76. @Override
  77. public List<Person> getAllPersonn(String userAccount) {
  78. String sql = "select * from person";
  79. return sd.getStudentList(sql);
  80. }
  81. @Override
  82. public void upAnswer(String answer,String taskAccount) {
  83. String sql = "update studenttask set studentAnswer = '"+answer+"' where taskAccount = "+taskAccount+"";
  84. sd.upAnswer(sql);
  85. }
  86. @Override
  87. public List<studentTask> getStuTaskByTask(String taskAccount) {
  88. String sql = "select * from studenttask where taskAccount = '"+taskAccount+"'";
  89. return sd.getStuTask(sql);
  90. }
  91. }
  1. package com.service;
  2. import com.Dao.TestDAO;
  3. import com.bean.Person;
  4. /**
  5. * @BelongsProject: MSTU1
  6. * @BelongsPackage: com.service
  7. * @FileName: UserLoginServiceImpl
  8. * @Author: 峰。
  9. * @Date: 2023/8/21-20:13
  10. * @Version: 1.0
  11. * @Description:
  12. */
  13. public class UserLoginServiceImpl implements UserLoginService{
  14. @Override
  15. public Person getLogin(Person person) {
  16. Person person1 = TestDAO.Login(person);
  17. return person1;
  18. }
  19. }

 Servlet包:

  1. package com.stu;
  2. import com.bean.Person;
  3. import com.bean.studentTask;
  4. import com.bean.task;
  5. import com.service.StudentService;
  6. import com.service.StudentServiceImpl;
  7. import com.service.commonService;
  8. import com.service.commonServiceImpl;
  9. import javafx.concurrent.Task;
  10. import javax.servlet.ServletException;
  11. import javax.servlet.annotation.WebServlet;
  12. import javax.servlet.http.HttpServlet;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import java.io.IOException;
  16. import java.util.ArrayList;
  17. import java.util.List;
  18. /**
  19. * @BelongsProject: MUST3
  20. * @BelongsPackage: com.stu
  21. * @FileName: CommonServlet
  22. * @Author: 峰。
  23. * @Date: 2023/8/22-19:51
  24. * @Version: 1.0
  25. * @Description:
  26. */
  27. @WebServlet("/common.action")
  28. public class CommonServlet extends HttpServlet {
  29. @Override
  30. protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  31. req.setCharacterEncoding("UTF-8");
  32. String action = req.getParameter("action");
  33. commonService sc = new commonServiceImpl();
  34. StudentService ss = new StudentServiceImpl();
  35. if (action.equals("index")){
  36. //转跳到首页
  37. req.setAttribute("mainRight","blank.jsp");
  38. req.getRequestDispatcher("main.jsp").forward(req,resp);
  39. } else if (action.equals("myThing")) {
  40. Person p = (Person) req.getSession().getAttribute("session_person");
  41. List<Person> personList= new ArrayList<>();
  42. personList.add(p);
  43. req.setAttribute("arr",personList);
  44. req.setAttribute("mainRight","SelfThing.jsp");
  45. req.getRequestDispatcher("main.jsp").forward(req,resp);
  46. } else if (action.equals("deletePerson")) {
  47. List<Person> personList = new ArrayList<>();
  48. String userAccount = req.getParameter("personAccount");
  49. sc.deletePerson(userAccount);
  50. Person session_person = (Person) req.getSession().getAttribute("session_person");
  51. if (session_person.getUserIdentify() == 0){
  52. personList = ss.getAllStudent(session_person.getUserAccount());
  53. } else if (session_person.getUserIdentify() == 2) {
  54. personList = ss.getAllPersonn(session_person.getUserAccount());
  55. }
  56. //获取学生列表
  57. for (Person p:personList){
  58. System.out.println(p.toString());
  59. }
  60. req.setAttribute("arr",personList);
  61. req.setAttribute("mainRight","person.jsp");
  62. req.getRequestDispatcher("main.jsp").forward(req,resp);
  63. } else if (action.equals("upStudent")) {
  64. String studentAccount = req.getParameter("student");
  65. List<Person> personList = ss.getMySelf(studentAccount);
  66. //获取学生列表
  67. for (Person p:personList){
  68. System.out.println(p.toString());
  69. }
  70. req.setAttribute("arr",personList);
  71. req.setAttribute("mainRight","upPerson.jsp");
  72. req.getRequestDispatcher("main.jsp").forward(req,resp);
  73. } else if (action.equals("upPersonName")) {
  74. String upName = req.getParameter("userName");
  75. String userAccount = req.getParameter("userAccount");
  76. ss.upName(upName,userAccount);
  77. List<Person> p = ss.getMySelf(userAccount);
  78. req.setAttribute("arr",p);
  79. req.setAttribute("mainRight","upPerson.jsp");
  80. req.getRequestDispatcher("main.jsp").forward(req,resp);
  81. }else if (action.equals("upPersonSex")) {
  82. String upSex = req.getParameter("userSex");
  83. String userAccount = req.getParameter("userAccount");
  84. ss.upSex(upSex,userAccount);
  85. List<Person> p = ss.getMySelf(userAccount);
  86. req.setAttribute("arr",p);
  87. req.setAttribute("mainRight","upPerson.jsp");
  88. req.getRequestDispatcher("main.jsp").forward(req,resp);
  89. }else if (action.equals("upPersonBirthday")) {
  90. String upBirthday = req.getParameter("userBirthday");
  91. String userAccount = req.getParameter("userAccount");
  92. ss.upBirthday(upBirthday,userAccount);
  93. List<Person> p = ss.getMySelf(userAccount);
  94. req.setAttribute("arr",p);
  95. req.setAttribute("mainRight","upPerson.jsp");
  96. req.getRequestDispatcher("main.jsp").forward(req,resp);
  97. }else if (action.equals("upPersonOtherName")) {
  98. String upOtherName = req.getParameter("OtherName");
  99. String userAccount = req.getParameter("userAccount");
  100. ss.upOtherName(upOtherName,userAccount);
  101. List<Person> p = ss.getMySelf(userAccount);
  102. req.setAttribute("arr",p);
  103. req.setAttribute("mainRight","upPerson.jsp");
  104. req.getRequestDispatcher("main.jsp").forward(req,resp);
  105. } else if (action.equals("list")) {
  106. Person session_person = (Person) req.getSession().getAttribute("session_person");
  107. List<Person> personList = ss.getAllPersonn(session_person.getUserAccount());
  108. //获取学生列表
  109. for (Person p:personList){
  110. System.out.println(p.toString());
  111. }
  112. req.setAttribute("arr",personList);
  113. req.setAttribute("mainRight","person.jsp");
  114. req.getRequestDispatcher("main.jsp").forward(req,resp);
  115. } else if (action.equals("selectTeacher")) {
  116. Person session_person = (Person) req.getSession().getAttribute("session_person");
  117. List<Person> teaList = sc.getAllTea();
  118. for (Person p:teaList){
  119. System.out.println(p.toString());
  120. }
  121. req.setAttribute("arr",teaList);
  122. req.setAttribute("mainRight","teaList.jsp");
  123. req.getRequestDispatcher("main.jsp").forward(req,resp);
  124. } else if (action.equals("MyTask")) {
  125. Person session_person = (Person) req.getSession().getAttribute("session_person");
  126. String userAccount = session_person.getUserAccount();
  127. List<studentTask> allMyTask = ss.getAllStuTask(userAccount);
  128. for (studentTask t:allMyTask){
  129. System.out.println(t.toString());
  130. }
  131. req.setAttribute("arr",allMyTask);
  132. req.setAttribute("mainRight","taskDetail.jsp");
  133. req.getRequestDispatcher("main.jsp").forward(req,resp);
  134. } else if (action.equals("selectPash")) {
  135. Person session_person = (Person) req.getSession().getAttribute("session_person");
  136. String userAccount = req.getParameter("userAccount");
  137. sc.selectPash(userAccount,session_person.getUserAccount());
  138. req.setAttribute("mainRight","blank.jsp");
  139. req.getRequestDispatcher("main.jsp").forward(req,resp);
  140. } else if (action.equals("goSkimDetail")) {
  141. String taskAccount = req.getParameter("taskAccount");
  142. List<studentTask> tasks = sc.selectTaskDetail(taskAccount);
  143. req.getSession().setAttribute("task",tasks.get(0));
  144. req.setAttribute("arr",tasks);
  145. req.setAttribute("mainRight","taskDetail.jsp");
  146. req.getRequestDispatcher("main.jsp").forward(req,resp);
  147. } else if (action.equals("upAnswer")) {
  148. String taskAccount = req.getParameter("taskAccount");
  149. List<studentTask> tasks = ss.getStuTaskByTask(taskAccount);
  150. req.setAttribute("arr",tasks);
  151. req.setAttribute("mainRight","upAnswer.jsp");
  152. req.getRequestDispatcher("main.jsp").forward(req,resp);
  153. } else if (action.equals("answer")) {
  154. String answer = req.getParameter("answer");
  155. String taskAccount = req.getParameter("taskAccount");
  156. ss.upAnswer(answer,taskAccount);
  157. List<studentTask> tasks = ss.getStuTaskByTask(taskAccount);
  158. req.getSession().setAttribute("task",tasks.get(0));
  159. req.setAttribute("arr",tasks);
  160. req.setAttribute("mainRight","taskDetail.jsp");
  161. req.getRequestDispatcher("main.jsp").forward(req,resp);
  162. }
  163. }
  164. }
  1. package com.stu;
  2. import com.bean.Person;
  3. import com.bean.task;
  4. import com.service.ManageService;
  5. import com.service.ManageServiceImpl;
  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.io.IOException;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. /**
  15. * @BelongsProject: MUST3
  16. * @BelongsPackage: com.stu
  17. * @FileName: ManageServlet
  18. * @Author: 峰。
  19. * @Date: 2023/8/22-20:00
  20. * @Version: 1.0
  21. * @Description:
  22. */
  23. @WebServlet("/man.action")
  24. public class ManageServlet extends HttpServlet {
  25. @Override
  26. protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  27. req.setCharacterEncoding("UTF-8");
  28. String action = req.getParameter("action");
  29. ManageService ms = new ManageServiceImpl();
  30. if (action.equals("list")){
  31. List<Person> personList = ms.getAllPerson();
  32. for (Person p :personList){
  33. System.out.println(p.toString());
  34. }
  35. req.setAttribute("arr",personList);
  36. req.setAttribute("mainRight","person.jsp");
  37. req.getRequestDispatcher("main.jsp").forward(req,resp);
  38. }else if (action.equals("myThing")) {
  39. Person p = (Person) req.getSession().getAttribute("session_person");
  40. List<Person> personList= new ArrayList<>();
  41. personList.add(p);
  42. req.setAttribute("arr",personList);
  43. req.setAttribute("mainRight","SelfThing.jsp");
  44. req.getRequestDispatcher("main.jsp").forward(req,resp);
  45. } else if (action.equals("taskList")) {
  46. Person p = (Person) req.getSession().getAttribute("session_person");
  47. List<task> taskList = ms.getAllTask();
  48. for (task t:taskList){
  49. System.out.println(t.toString());
  50. }
  51. req.setAttribute("arr",taskList);
  52. req.setAttribute("mainRight","task.jsp");
  53. req.getRequestDispatcher("main.jsp").forward(req,resp);
  54. }
  55. }
  56. }
  1. package com.stu;
  2. import javax.servlet.ServletException;
  3. import javax.servlet.annotation.WebServlet;
  4. import javax.servlet.http.HttpServlet;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import javax.servlet.http.HttpSession;
  8. import java.io.IOException;
  9. /**
  10. * @BelongsProject: MUST3
  11. * @BelongsPackage: com.stu
  12. * @FileName: OutLoginServlet
  13. * @Author: 峰。
  14. * @Date: 2023/8/22-21:18
  15. * @Version: 1.0
  16. * @Description:
  17. */
  18. @WebServlet("/outLogin")
  19. public class OutLoginServlet extends HttpServlet {
  20. @Override
  21. protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  22. req.getSession().getAttribute("session_person");
  23. HttpSession session = req.getSession();
  24. session.removeAttribute("session_person");
  25. req.getRequestDispatcher("UserLogin.jsp").forward(req,resp);
  26. }
  27. }
  1. package com.stu;
  2. import com.bean.Person;
  3. import com.service.registerService;
  4. import com.service.registerServiceImpl;
  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. * @BelongsProject: MUST3
  13. * @BelongsPackage: com.stu
  14. * @FileName: regServlet
  15. * @Author: 峰。
  16. * @Date: 2023/8/24-18:11
  17. * @Version: 1.0
  18. * @Description:
  19. */
  20. @WebServlet("/regServlet")
  21. public class regServlet extends HttpServlet {
  22. @Override
  23. protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  24. req.setCharacterEncoding("UTF-8");
  25. registerService rs = new registerServiceImpl();
  26. Person person = new Person();
  27. person.setUserAccount(req.getParameter("userAccount"));
  28. person.setUserPassword(req.getParameter("userPassword"));
  29. person.setUserBirthday(req.getParameter("userBirthday"));
  30. person.setUserIdentify(1);
  31. person.setUserName(req.getParameter("userName"));
  32. person.setUserSex(req.getParameter("userSex"));
  33. person.setUserOtherName(req.getParameter("userOtherName"));
  34. System.out.println(person.toString());
  35. int bool = rs.addUser(person);
  36. if (bool == 1){
  37. req.getRequestDispatcher("UserLogin.jsp").forward(req,resp);
  38. }else {
  39. req.setAttribute("registerFalse","注册失败");
  40. req.getRequestDispatcher("UserLogin.jsp").forward(req,resp);
  41. }
  42. }
  43. }
  1. package com.stu;
  2. import com.bean.Person;
  3. import com.bean.studentTask;
  4. import com.bean.task;
  5. import com.service.StudentService;
  6. import com.service.StudentServiceImpl;
  7. import javax.servlet.ServletException;
  8. import javax.servlet.annotation.WebServlet;
  9. import javax.servlet.http.HttpServlet;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12. import java.io.IOException;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. /**
  16. * @BelongsProject: MUST3
  17. * @BelongsPackage: com.stu
  18. * @FileName: TeacherServlet
  19. * @Author: 峰。
  20. * @Date: 2023/8/22-19:59
  21. * @Version: 1.0
  22. * @Description:
  23. */
  24. @WebServlet("/tea.action")
  25. public class TeacherServlet extends HttpServlet {
  26. @Override
  27. protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  28. req.setCharacterEncoding("UTF-8");
  29. String action = req.getParameter("action");
  30. StudentService ss = new StudentServiceImpl();
  31. // Person session_person = (Person) req.getAttribute("session_person");直接获取拿不到person对象,需要通过session获取
  32. Person session_person = (Person) req.getSession().getAttribute("session_person");
  33. if (action.equals("list")){
  34. List<Person> personList = ss.getAllStudent(session_person.getUserAccount());
  35. //获取学生列表
  36. for (Person p:personList){
  37. System.out.println(p.toString());
  38. }
  39. req.setAttribute("arr",personList);
  40. req.setAttribute("mainRight","person.jsp");
  41. req.getRequestDispatcher("main.jsp").forward(req,resp);
  42. } else if (action.equals("goMyTask")) {
  43. List<task> taskList = ss.getAllMyTask(session_person.getUserAccount());
  44. for (task t:taskList){
  45. System.out.println(t.toString());
  46. }
  47. req.setAttribute("arr",taskList);
  48. req.setAttribute("mainRight","task.jsp");
  49. req.getRequestDispatcher("main.jsp").forward(req,resp);
  50. } else if (action.equals("goSkimDetail")) {
  51. //查看任务
  52. String taskAccount = req.getParameter("taskAccount");
  53. List<studentTask> taskList= ss.getTaskDetail(taskAccount);
  54. req.setAttribute("arr",taskList);
  55. req.setAttribute("mainRight","studentTask.jsp");
  56. req.getRequestDispatcher("main.jsp").forward(req,resp);
  57. } else if (action.equals("myThing")) {
  58. List<Person> personList = ss.getMySelf(session_person.getUserAccount());
  59. req.setAttribute("arr",personList);
  60. req.setAttribute("mainRight","SelfThing.jsp");
  61. req.getRequestDispatcher("main.jsp").forward(req,resp);
  62. } else if (action.equals("upScoree")) {
  63. String taskAccount = req.getParameter("taskAccount");
  64. int upScore = Integer.parseInt(req.getParameter("Score"));
  65. int res = ss.upScore(upScore,taskAccount);
  66. if (res == 1){
  67. List<studentTask> taskList= ss.getTaskDetail(taskAccount);
  68. req.setAttribute("arr",taskList);
  69. req.setAttribute("mainRight","studentTask.jsp");
  70. req.getRequestDispatcher("main.jsp").forward(req,resp);
  71. }
  72. } else if (action.equals("upScore")) {
  73. String taskAccount = req.getParameter("taskAccount");
  74. List<studentTask> taskList= ss.getTaskDetail(taskAccount);
  75. req.setAttribute("arr",taskList);
  76. req.setAttribute("mainRight","upScore.jsp");
  77. req.getRequestDispatcher("main.jsp").forward(req,resp);
  78. } else if (action.equals("Del")) {
  79. String taskAccount = req.getParameter("taskAccount");
  80. int res = ss.DelTask(taskAccount);
  81. List<task> taskList = ss.getAllMyTask(session_person.getUserAccount());
  82. for (task t : taskList) {
  83. System.out.println(t.toString());
  84. }
  85. req.setAttribute("arr", taskList);
  86. req.setAttribute("mainRight", "task.jsp");
  87. req.getRequestDispatcher("main.jsp").forward(req, resp);
  88. } else if (action.equals("upSelf")) {
  89. Person p = (Person) req.getSession().getAttribute("session_person");
  90. List<Person> personList= new ArrayList<>();
  91. personList.add(p);
  92. req.setAttribute("arr",personList);
  93. req.setAttribute("mainRight","upSelf.jsp");
  94. req.getRequestDispatcher("main.jsp").forward(req,resp);
  95. } else if (action.equals("upSelfName")) {
  96. System.out.println("111");
  97. String upName = req.getParameter("userName");
  98. String userAccount = req.getParameter("userAccount");
  99. System.out.println(upName);
  100. ss.upName(upName,userAccount);
  101. List<Person> p = ss.getMySelf(userAccount);
  102. req.setAttribute("arr",p);
  103. req.setAttribute("mainRight","upSelf.jsp");
  104. req.getRequestDispatcher("main.jsp").forward(req,resp);
  105. } else if (action.equals("upSelfSex")) {
  106. String upSex = req.getParameter("userSex");
  107. String userAccount = req.getParameter("userAccount");
  108. ss.upSex(upSex,userAccount);
  109. List<Person> p = ss.getMySelf(userAccount);
  110. req.setAttribute("arr",p);
  111. req.setAttribute("mainRight","upSelf.jsp");
  112. req.getRequestDispatcher("main.jsp").forward(req,resp);
  113. } else if (action.equals("upSelfBirthday")) {
  114. String upBirthday = req.getParameter("userBirthday");
  115. String userAccount = req.getParameter("userAccount");
  116. ss.upBirthday(upBirthday,userAccount);
  117. List<Person> p = ss.getMySelf(userAccount);
  118. req.setAttribute("arr",p);
  119. req.setAttribute("mainRight","upSelf.jsp");
  120. req.getRequestDispatcher("main.jsp").forward(req,resp);
  121. }else if (action.equals("upSelfOtherName")){
  122. String upOtherName = req.getParameter("OtherName");
  123. String userAccount = req.getParameter("userAccount");
  124. ss.upOtherName(upOtherName,userAccount);
  125. List<Person> p = ss.getMySelf(userAccount);
  126. req.setAttribute("arr",p);
  127. req.setAttribute("mainRight","upSelf.jsp");
  128. req.getRequestDispatcher("main.jsp").forward(req,resp);
  129. }
  130. }
  131. }
  1. package com.stu;
  2. import com.Dao.TestDAO;
  3. import com.bean.Person;
  4. import com.service.UserLoginService;
  5. import com.service.UserLoginServiceImpl;
  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.io.IOException;
  12. /**
  13. * @BelongsProject: MSTU1
  14. * @BelongsPackage: com.stu
  15. * @FileName: UserLoginServlet
  16. * @Author: 峰。
  17. * @Date: 2023/8/20-19:25
  18. * @Version: 1.0
  19. * @Description:
  20. */
  21. @WebServlet("/UserLogin")
  22. public class UserLoginServlet extends HttpServlet {
  23. @Override
  24. protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  25. // System.out.println("进来了");
  26. //1.拿到前端传递过来的信息,比方说用户名和密码
  27. String username = req.getParameter("userAccount");
  28. String password = req.getParameter("userPassword");
  29. Person person = new Person(username,password);
  30. // Person person1 = TestDAO.Login(person);
  31. UserLoginService uls = new UserLoginServiceImpl();
  32. Person person1 = uls.getLogin(person);
  33. // if (username.equals("admin") && password.equals("word")){
  34. if (username.equals(person1.getUserAccount())&&password.equals(person1.getUserPassword())){
  35. // 进入主页面
  36. System.out.println(person1);
  37. req.getSession().setAttribute("session_person",person1);//默认保存30分钟
  38. // req.setAttribute("person",person1);
  39. req.setAttribute("mainRight","blank.jsp");
  40. req.getRequestDispatcher("main.jsp").forward(req,resp);
  41. }else {
  42. // 否则,跳回登录界面
  43. req.setAttribute("tip","账户密码错误");
  44. req.getRequestDispatcher("UserLogin.jsp").forward(req,resp);//转跳回界面
  45. }
  46. }
  47. }

数据库连接信息:

  1. driver=com.mysql.cj.jdbc.Driver
  2. url=jdbc:mysql://localhost:3306/db_it1
  3. user=root
  4. password=wbf

静态页面(其中用到的一些图片需要自己提供):

  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/21
  5. Time: 19:14
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. #content{
  14. width: 1300px;
  15. height: 800px;
  16. /*border: 1px solid red;*/
  17. float: right;
  18. color: grey;
  19. font-size: 50px;
  20. /*margin-right: 40px;*/
  21. /*margin-left: 260px;*/
  22. /*margin-top: 150px;*/
  23. }
  24. </style>
  25. </head>
  26. <body >
  27. <div id="content">
  28. 欢迎来到此系统
  29. </div>
  30. </body>
  31. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 15:19
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">任务账户</td>
  52. <td class="lf">任务名称</td>
  53. <td class="lf">任务时间</td>
  54. <td class="lf">查看详细</td>
  55. <%-- <td>删除</td>--%>
  56. <%-- <td>修改</td>--%>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. <tr>
  61. <c:forEach items="${arr}" var="task">
  62. <td class="lf">${task.getTask()}</td>
  63. <td class="lf">${task.getTaskName()}</td>
  64. <td class="lf">${task.getTaskDate()}</td>
  65. <td class="lf"><img style="width: 73px;height: 44px" src="xiangqing.png" onclick="skimDetail(${task.getTask()})"></td>
  66. <%-- <td class="lf">${person.getUserIdCard()}</td>--%>
  67. <%-- <td class="lf">--%>
  68. <%-- <c:if test="${person.getUserIdentify()==0}">学生</c:if>--%>
  69. <%-- <c:if test="${person.getUserIdentify()==1}">老师</c:if>--%>
  70. <%-- </td>--%>
  71. <%-- <td class="lf">${person.getUserOtherName()}</td>--%>
  72. <%-- <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>--%>
  73. <%-- <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>--%>
  74. </tr>
  75. </c:forEach>
  76. </tr>
  77. </tbody>
  78. </table>
  79. </body>
  80. <script>
  81. function skimDetail(taskAccount){
  82. //查看学生任务完成情况
  83. window.location.href = "common.action?action=goSkimDetail&taskAccount="+taskAccount;
  84. }
  85. </script>
  86. <%--<script>--%>
  87. <%-- function deleteThis(userAccount){--%>
  88. <%-- alert(userAccount);--%>
  89. <%-- }--%>
  90. <%-- function upThis(userAccount){--%>
  91. <%-- alert(userAccount);--%>
  92. <%-- }--%>
  93. <%--</script>--%>
  94. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/18
  5. Time: 13:46
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>$Title$</title>
  12. </head>
  13. <body>
  14. <script>
  15. window.location.href = "UserLogin.jsp";
  16. </script>
  17. </body>
  18. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/20
  5. Time: 21:39
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. #BigBodyFrame{
  14. width: 1500px;
  15. height: 120px;
  16. /*margin-left:200px;*/
  17. border: grey 1px solid;
  18. background-image: url("VCG211448478478.jpg");
  19. }
  20. #daohang{
  21. width: 200px;
  22. height: 320px;
  23. border: grey 1px solid;
  24. float: left;
  25. }
  26. #file{
  27. width: 180px;
  28. height: 50px;
  29. margin-left: 10px;
  30. margin-top: 10px;
  31. border: grey 1px solid;
  32. background-color: antiquewhite;
  33. }
  34. a{
  35. color: black;
  36. font-size: 26px;
  37. margin-left: 15px;
  38. margin-top: 15px;
  39. }
  40. </style>
  41. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  42. <link href="${pageContext.request.contextPath}/css/table.css" rel="stylesheet" media="screen">
  43. </head>
  44. <body>
  45. <div id="BigBodyFrame"></div>
  46. <br>
  47. <br>
  48. <span style="float: right; margin-right: 100px; color: grey">当前用户:${session_person.userName}</span>
  49. <%-- <a href="#">修改密码</a>--%>
  50. <br>
  51. <div id="daohang">
  52. <c:if test="${session_person.getUserIdentify()==0}">
  53. <li id="file"><a href="common.action?action=index">查看首页</a></li>
  54. <%-- 回到首页的动作--%>
  55. <li id="file"><a href="tea.action?action=list">学生管理</a></li>
  56. <li id="file"><a href="tea.action?action=goMyTask">任务管理</a></li>
  57. <li id="file"><a href="tea.action?action=myThing">我的信息</a></li>
  58. <li id="file"><a href="outLogin">退出系统</a></li>
  59. </c:if>
  60. <c:if test="${session_person.getUserIdentify()==1}">
  61. <li id="file"><a href="common.action?action=index">查看首页</a></li>
  62. <li id="file"><a href="common.action?action=selectTeacher">选择老师</a></li>
  63. <li id="file"><a href="common.action?action=MyTask">我的任务</a></li>
  64. <li id="file"><a href="common.action?action=myThing">我的信息</a></li>
  65. <li id="file"><a href="outLogin">退出系统</a></li>
  66. </c:if>
  67. <c:if test="${session_person.getUserIdentify()==2}">
  68. <li id="file"><a href="common.action?action=index">查看首页</a></li>
  69. <li id="file"><a href="man.action?action=list">人员管理</a></li>
  70. <li id="file"><a href="man.action?action=taskList">任务管理</a></li>
  71. <li id="file"><a href="man.action?action=myThing">我的信息</a></li>
  72. <li id="file"><a href="outLogin">退出系统</a></li>
  73. </c:if>
  74. <%-- <div id="file" onclick="clickThis()"></div>--%>
  75. </div>
  76. <jsp:include page="${mainRight = null?'blank.jsp':mainRight}"></jsp:include>
  77. <%--<jsp:include page="${downJSP = null ;downJSP}"></jsp:include>--%>
  78. <%--mainRight是从后端传过来的数据值--%>
  79. </body>
  80. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/22
  5. Time: 19:57
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%--
  9. Created by IntelliJ IDEA.
  10. User: 30890
  11. Date: 2023/4/17
  12. Time: 9:47
  13. To change this template use File | Settings | File Templates.
  14. --%>
  15. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  16. <html>
  17. <head>
  18. <title>Title</title>
  19. <style>
  20. table{
  21. width: 1200px;
  22. }
  23. tr,td{
  24. border: grey 1px ;
  25. }
  26. td{
  27. height: 40px;
  28. }
  29. table td{
  30. height: 60px;
  31. vertical-align: middle!important; /*设置文字垂直居中*/
  32. text-align: center;
  33. }
  34. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  35. th{font-weight:bold;background:#ccc;}
  36. .con-b .row .lf{
  37. width: 15%;
  38. text-align: center;
  39. padding: 10px;
  40. }
  41. .con-b .row .rg{
  42. width: 85%;
  43. }
  44. .con-b tr:nth-of-type(odd){
  45. background-color: #f2f2f2;
  46. }
  47. #ee{
  48. width: 73px;
  49. height: 44px;
  50. }
  51. </style>
  52. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  53. </head>
  54. <body>
  55. <table border="1" cellspacing="0" align="center" class="con-b">
  56. <thead>
  57. <tr class="row" style="color: black;font-size: 25px" >
  58. <td class="lf">账户</td>
  59. <td class="lf">姓名</td>
  60. <td class="lf">性别</td>
  61. <td class="lf">生日</td>
  62. <td class="lf">身份证号码</td>
  63. <td class="lf">角色</td>
  64. <td class="lf">其他名称</td>
  65. <td class="lf">删除</td>
  66. <td class="lf">修改</td>
  67. </tr>
  68. </thead>
  69. <tbody>
  70. <tr>
  71. <c:forEach items="${arr}" var="person">
  72. <td class="lf">${person.getUserAccount()}</td>
  73. <td class="lf">${person.getUserName()}</td>
  74. <td class="lf">${person.getUserSex()}</td>
  75. <td class="lf">${person.getUserBirthday()}</td>
  76. <td class="lf">${person.getUserIdCard()}</td>
  77. <td class="lf">
  78. <c:if test="${person.getUserIdentify()==0}">老师</c:if>
  79. <c:if test="${person.getUserIdentify()==1}">学生</c:if>
  80. <c:if test="${person.getUserIdentify()==2}">管理员</c:if>
  81. </td>
  82. <td class="lf">${person.getUserOtherName()}</td>
  83. <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>
  84. <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>
  85. </tr>
  86. </c:forEach>
  87. </tr>
  88. </tbody>
  89. </table>
  90. </body>
  91. <script>
  92. function deleteThis(userAccount){
  93. // alert("userAccount");
  94. window.location.href="common.action?action=deletePerson&personAccount="+userAccount;
  95. }
  96. function upThis(userAccount){
  97. window.location.href="common.action?action=upStudent&student="+userAccount;
  98. }
  99. </script>
  100. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/24
  5. Time: 17:48
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>注册界面</title>
  12. <style>
  13. #outerLoginFrame{
  14. width: 500px;
  15. height: 600px;
  16. margin-left: 500px;
  17. margin-top: 120px;
  18. border: white 0px solid;
  19. }
  20. #innerLoginFrame{
  21. width: 360px;
  22. /*border: grey 2px solid;*/
  23. margin-left: 80px;
  24. margin-top: 50px;
  25. height: 250px;
  26. color: grey;
  27. font-size: 25px;
  28. }
  29. input{
  30. width: 220px;
  31. height: 30px;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div id="outerLoginFrame" style="border:grey 2px solid">
  37. <%-- <span style="position: center"></span>--%>
  38. <h1 style="margin-top: 40px;margin-left: 160px;color: grey">注&nbsp册&nbsp账&nbsp号</h1>
  39. <div id="innerLoginFrame">
  40. <form action="regServlet" method="post" onclick=" return checkRegister()">
  41. 账户:<input type="text" id="userAccount" name="userAccount" class="myText"><br><br>
  42. 姓名:<input type="text" id="userName" name="userName" class="myText"><br><br>
  43. 密码:<input type="password" id="userPassword" name="userPassword" class="myText"><br><br>
  44. 性别:<input type="text" id="userSex" name="userSex" class="myText"><br><br>
  45. 生日:<input type="text" id="userBirthday" name="userBirthday" class="myText"><br><br>
  46. 别称:<input type="text" id="userOtherName" name="userOtherName" class="myText"><br><br>
  47. <input type="submit" style="width: 140px ;margin-left :60px" value="注册">
  48. <br>
  49. <span style="color:red; font-size: 5px; margin-left: 90px" id="tip" ></span>
  50. </form>
  51. </div>
  52. </div>
  53. </body>
  54. </html>
  55. <script>
  56. <%-- 方法--%>
  57. function checkRegister(){
  58. // alert("进来") 弹窗
  59. let userAccount = document.getElementById("userAccount").value;
  60. let userPassword = document.getElementById("userPassword").value;
  61. let userName = document.getElementById("userName").value;
  62. let userSex = document.getElementById("userSex").value;
  63. let userBirthday = document.getElementById("userBirthday").value;
  64. let userOtherName = document.getElementById("userOtherName").value;
  65. if (userAccount == null || userAccount.trim()==""){
  66. // alert("账户不能为空");
  67. document.getElementById("tip").innerHTML = "账户不能为空";
  68. return false;
  69. }
  70. else if (userPassword == null || userPassword.trim()==""){
  71. // alert("密码不能为空");
  72. document.getElementById("tip").innerHTML = "密码不能为空";
  73. return false;
  74. } else if (userName == null || userName.trim()==""){
  75. // alert("密码不能为空");
  76. document.getElementById("tip").innerHTML = "请输入名称";
  77. return false;
  78. } else if (userSex == null || userSex.trim()==""){
  79. // alert("密码不能为空");
  80. document.getElementById("tip").innerHTML = "请填写性别!";
  81. return false;
  82. } else if (userBirthday == null || userBirthday.trim()==""){
  83. // alert("密码不能为空");
  84. document.getElementById("tip").innerHTML = "请填写生日日期!";
  85. return false;
  86. }else if (userOtherName == null || userOtherName.trim()==""){
  87. // alert("密码不能为空");
  88. document.getElementById("tip").innerHTML = "请填写别称!";
  89. return false;
  90. }
  91. }
  92. </script>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 18:37
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">账户</td>
  52. <td class="lf">姓名</td>
  53. <td class="lf">性别</td>
  54. <td class="lf">生日</td>
  55. <td class="lf">身份证号码</td>
  56. <td class="lf">角色</td>
  57. <td class="lf">其他名称</td>
  58. <td class="lf">修改</td>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. <tr>
  63. <c:forEach items="${arr}" var="person">
  64. <td class="lf">${person.getUserAccount()}</td>
  65. <td class="lf">${person.getUserName()}</td>
  66. <td class="lf">${person.getUserSex()}</td>
  67. <td class="lf">${person.getUserBirthday()}</td>
  68. <td class="lf">${person.getUserIdCard()}</td>
  69. <td class="lf">
  70. <c:if test="${person.getUserIdentify()==1}">学生</c:if>
  71. <c:if test="${person.getUserIdentify()==0}">老师</c:if>
  72. <c:if test="${person.getUserIdentify()==2}">管理员</c:if>
  73. </td>
  74. <td class="lf">${person.getUserOtherName()}</td>
  75. <td class="lf"><img style="width: 83px;height: 44px" src="xiugai.png" onclick="upThis(${person.getUserIdentify()})"> </td>
  76. </tr>
  77. </c:forEach>
  78. </tr>
  79. </tbody>
  80. </table>
  81. <script>
  82. function upThis(Identify){
  83. // window.location.href="tea.action?action=upSelf&userAccount="+userAccount;
  84. // alert(userAccount)
  85. if (Identify == 0){
  86. window.location.href="tea.action?action=upSelf";
  87. }
  88. if (Identify == 1){
  89. window.location.href="tea.action?action=upSelf";
  90. }
  91. if (Identify == 2){
  92. window.location.href="tea.action?action=upSelf";
  93. }
  94. }
  95. </script>
  96. </body>
  97. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 17:14
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">任务</td>
  52. <td class="lf">学生账户</td>
  53. <td class="lf">学生姓名</td>
  54. <td class="lf">学生答案</td>
  55. <td class="lf">是否完成</td>
  56. <td class="lf">分数</td>
  57. <td class="lf">修改分数</td>
  58. <td>删除</td>
  59. <%-- <td>查看评论</td>--%>
  60. <%-- <td>删除</td>--%>
  61. <%-- <td>修改</td>--%>
  62. </tr>
  63. </thead>
  64. <tbody>
  65. <tr>
  66. <c:forEach items="${arr}" var="taskDetail">
  67. <td class="lf">${taskDetail.getTaskAccount()}</td>
  68. <td class="lf">${taskDetail.getStudentAccount()}</td>
  69. <td class="lf">${taskDetail.getStudentName()}</td>
  70. <td class="lf">${taskDetail.getStudentAnswer()}</td>
  71. <td class="lf">
  72. <c:if test="${taskDetail.getIsFinish()==0}"><span style="color: red">未完成</span></c:if>
  73. <c:if test="${taskDetail.getIsFinish()==1}"><span style="color: aqua">已完成</span></c:if>
  74. </td>
  75. <td class="lf">${taskDetail.getScore()}</td>
  76. <td class="lf"><img style="width: 83px;height: 44px" src="xiugai.png" onclick="upScore(${taskDetail.getTaskAccount()})"> </td>
  77. <td><img style="width: 83px;height: 44px" src="shanchu.png"
  78. onclick="Del(${taskDetail.getTaskAccount()})"></td>
  79. <%-- <td class="lf">${person.getUserIdCard()}</td>--%>
  80. <%-- <td class="lf">--%>
  81. <%-- <c:if test="${person.getUserIdentify()==0}">学生</c:if>--%>
  82. <%-- <c:if test="${person.getUserIdentify()==1}">老师</c:if>--%>
  83. <%-- </td>--%>
  84. <%-- <td class="lf">${person.getUserOtherName()}</td>--%>
  85. <%-- <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>--%>
  86. <%-- <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>--%>
  87. </tr>
  88. </c:forEach>
  89. </tr>
  90. </tbody>
  91. </table>
  92. </body>
  93. <script>
  94. function upScore(taskAccount){
  95. window.location.href="tea.action?action=upScore&taskAccount="+taskAccount;
  96. }
  97. function Del(taskAccount){
  98. window.location.href="tea.action?action=Del&taskAccount="+taskAccount;
  99. }
  100. </script>
  101. <%--<script>--%>
  102. <%-- function skimDetail(taskAccount){--%>
  103. <%-- //查看学生任务完成情况--%>
  104. <%-- window.location.href = "tea.action?action=goSkimDetail&taskAccount="+taskAccount;--%>
  105. <%-- }--%>
  106. <%--</script>--%>
  107. <%--<script>--%>
  108. <%-- function deleteThis(userAccount){--%>
  109. <%-- alert(userAccount);--%>
  110. <%-- }--%>
  111. <%-- function upThis(userAccount){--%>
  112. <%-- alert(userAccount);--%>
  113. <%-- }--%>
  114. <%--</script>--%>
  115. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 15:19
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">任务账户</td>
  52. <td class="lf">任务名称</td>
  53. <td class="lf">任务时间</td>
  54. <td class="lf">查看详细</td>
  55. <%-- <td>删除</td>--%>
  56. <%-- <td>修改</td>--%>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. <tr>
  61. <c:forEach items="${arr}" var="task">
  62. <td class="lf">${task.getTask()}</td>
  63. <td class="lf">${task.getTaskName()}</td>
  64. <td class="lf">${task.getTaskDate()}</td>
  65. <td class="lf"><img style="width: 73px;height: 44px" src="xiangqing.png" onclick="skimDetail(${task.getTask()})"></td>
  66. <%-- <td class="lf">${person.getUserIdCard()}</td>--%>
  67. <%-- <td class="lf">--%>
  68. <%-- <c:if test="${person.getUserIdentify()==0}">学生</c:if>--%>
  69. <%-- <c:if test="${person.getUserIdentify()==1}">老师</c:if>--%>
  70. <%-- </td>--%>
  71. <%-- <td class="lf">${person.getUserOtherName()}</td>--%>
  72. <%-- <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>--%>
  73. <%-- <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>--%>
  74. </tr>
  75. </c:forEach>
  76. </tr>
  77. </tbody>
  78. </table>
  79. </body>
  80. <script>
  81. function skimDetail(taskAccount){
  82. //查看学生任务完成情况
  83. window.location.href = "tea.action?action=goSkimDetail&taskAccount="+taskAccount;
  84. }
  85. </script>
  86. <%--<script>--%>
  87. <%-- function deleteThis(userAccount){--%>
  88. <%-- alert(userAccount);--%>
  89. <%-- }--%>
  90. <%-- function upThis(userAccount){--%>
  91. <%-- alert(userAccount);--%>
  92. <%-- }--%>
  93. <%--</script>--%>
  94. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 17:14
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">任务</td>
  52. <%-- <td class="lf">学生账户</td>--%>
  53. <%-- <td class="lf">学生姓名</td>--%>
  54. <td class="lf">学生答案</td>
  55. <td class="lf">是否完成</td>
  56. <td class="lf">分数</td>
  57. <td class="lf">修改</td>
  58. <%-- <td>查看评论</td>--%>
  59. <%-- <td>删除</td>--%>
  60. <%-- <td>修改</td>--%>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr>
  65. <c:forEach items="${arr}" var="taskDetail">
  66. <td class="lf">${taskDetail.getTaskAccount()}</td>
  67. <%-- <td class="lf">${taskDetail.getStudentAccount()}</td>--%>
  68. <%-- <td class="lf">${taskDetail.getStudentName()}</td>--%>
  69. <td class="lf">${taskDetail.getStudentAnswer()}</td>
  70. <td class="lf">
  71. <c:if test="${taskDetail.getIsFinish()==0}"><span style="color: red">未完成</span></c:if>
  72. <c:if test="${taskDetail.getIsFinish()==1}"><span style="color: aqua">已完成</span></c:if>
  73. </td>
  74. <td class="lf">${taskDetail.getScore()}</td>
  75. <td class="lf"><img style="width: 83px;height: 44px" src="xiugai.png" onclick="upAnswer(${taskDetail.getTaskAccount()})"> </td>
  76. <%-- <td class="lf">${person.getUserIdCard()}</td>--%>
  77. <%-- <td class="lf">--%>
  78. <%-- <c:if test="${person.getUserIdentify()==0}">学生</c:if>--%>
  79. <%-- <c:if test="${person.getUserIdentify()==1}">老师</c:if>--%>
  80. <%-- </td>--%>
  81. <%-- <td class="lf">${person.getUserOtherName()}</td>--%>
  82. <%-- <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>--%>
  83. <%-- <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>--%>
  84. </tr>
  85. </c:forEach>
  86. </tr>
  87. </tbody>
  88. </table>
  89. </body>
  90. <script>
  91. function upAnswer(taskAccount){
  92. window.location.href="common.action?action=upAnswer&taskAccount="+taskAccount;
  93. }
  94. </script>
  95. <%--<script>--%>
  96. <%-- function skimDetail(taskAccount){--%>
  97. <%-- //查看学生任务完成情况--%>
  98. <%-- window.location.href = "tea.action?action=goSkimDetail&taskAccount="+taskAccount;--%>
  99. <%-- }--%>
  100. <%--</script>--%>
  101. <%--<script>--%>
  102. <%-- function deleteThis(userAccount){--%>
  103. <%-- alert(userAccount);--%>
  104. <%-- }--%>
  105. <%-- function upThis(userAccount){--%>
  106. <%-- alert(userAccount);--%>
  107. <%-- }--%>
  108. <%--</script>--%>
  109. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/22
  5. Time: 19:57
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%--
  9. Created by IntelliJ IDEA.
  10. User: 30890
  11. Date: 2023/4/17
  12. Time: 9:47
  13. To change this template use File | Settings | File Templates.
  14. --%>
  15. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  16. <html>
  17. <head>
  18. <title>Title</title>
  19. <style>
  20. table{
  21. width: 1200px;
  22. }
  23. tr,td{
  24. border: grey 1px ;
  25. }
  26. td{
  27. height: 40px;
  28. }
  29. table td{
  30. height: 60px;
  31. vertical-align: middle!important; /*设置文字垂直居中*/
  32. text-align: center;
  33. }
  34. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  35. th{font-weight:bold;background:#ccc;}
  36. .con-b .row .lf{
  37. width: 15%;
  38. text-align: center;
  39. padding: 10px;
  40. }
  41. .con-b .row .rg{
  42. width: 85%;
  43. }
  44. .con-b tr:nth-of-type(odd){
  45. background-color: #f2f2f2;
  46. }
  47. #ee{
  48. width: 73px;
  49. height: 44px;
  50. }
  51. </style>
  52. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  53. </head>
  54. <body>
  55. <table border="1" cellspacing="0" align="center" class="con-b">
  56. <thead>
  57. <tr class="row" style="color: black;font-size: 25px" >
  58. <td class="lf">姓名</td>
  59. <td class="lf">性别</td>
  60. <td class="lf">角色</td>
  61. <td class="lf">其他名称</td>
  62. <td class="lf">选择</td>
  63. </tr>
  64. </thead>
  65. <tbody>
  66. <tr>
  67. <c:forEach items="${arr}" var="person">
  68. <td class="lf">${person.getUserName()}</td>
  69. <td class="lf">${person.getUserSex()}</td>
  70. <td class="lf">
  71. <c:if test="${person.getUserIdentify()==0}">老师</c:if>
  72. <c:if test="${person.getUserIdentify()==1}">学生</c:if>
  73. <c:if test="${person.getUserIdentify()==2}">管理员</c:if>
  74. </td>
  75. <td class="lf">${person.getUserOtherName()}</td>
  76. <td ><img style="width: 73px;height: 44px" src="xuanze.png" onclick="selectThis('${person.getUserAccount()}')"> </td>
  77. </tr>
  78. </c:forEach>
  79. </tr>
  80. </tbody>
  81. </table>
  82. </body>
  83. <script>
  84. function selectThis(userAccount){
  85. window.location.href="common.action?action=selectPash&userAccount="+userAccount;
  86. }
  87. </script>
  88. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 17:14
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">任务</td>
  52. <%-- <td class="lf">学生账户</td>--%>
  53. <%-- <td class="lf">学生姓名</td>--%>
  54. <td class="lf">学生答案</td>
  55. <td class="lf">是否完成</td>
  56. <td class="lf">分数</td>
  57. <td class="lf">修改</td>
  58. <%-- <td>查看评论</td>--%>
  59. <%-- <td>删除</td>--%>
  60. <%-- <td>修改</td>--%>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr>
  65. <c:forEach items="${arr}" var="taskDetail">
  66. <td class="lf">${taskDetail.getTaskAccount()}</td>
  67. <%-- <td class="lf">${taskDetail.getStudentAccount()}</td>--%>
  68. <%-- <td class="lf">${taskDetail.getStudentName()}</td>--%>
  69. <td class="lf"> <form action="common.action?action=answer&taskAccount=${taskDetail.getTaskAccount()}" method="post">
  70. <input placeholder="${taskDetail.getStudentAnswer()}" type="text" id="answer" name="answer" class="lf">
  71. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return answerPash()" value="提交">
  72. <span style="color:red; font-size: 5px" id="tip" ></span>
  73. </form></td>
  74. <td class="lf">
  75. <c:if test="${taskDetail.getIsFinish()==0}"><span style="color: red">未完成</span></c:if>
  76. <c:if test="${taskDetail.getIsFinish()==1}"><span style="color: aqua">已完成</span></c:if>
  77. </td>
  78. <td class="lf">${taskDetail.getScore()}</td>
  79. <td class="lf"><img style="width: 83px;height: 44px" src="xiugai.png" onclick="upAnswer(${taskDetail.getTaskAccount()})"> </td>
  80. <%-- <td class="lf">${person.getUserIdCard()}</td>--%>
  81. <%-- <td class="lf">--%>
  82. <%-- <c:if test="${person.getUserIdentify()==0}">学生</c:if>--%>
  83. <%-- <c:if test="${person.getUserIdentify()==1}">老师</c:if>--%>
  84. <%-- </td>--%>
  85. <%-- <td class="lf">${person.getUserOtherName()}</td>--%>
  86. <%-- <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>--%>
  87. <%-- <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>--%>
  88. </tr>
  89. </c:forEach>
  90. </tr>
  91. </tbody>
  92. </table>
  93. </body>
  94. <script>
  95. function upAnswer(taskAccount){
  96. let answer = document.getElementById("answer").value;
  97. if (answer == null || answer.trim()==""){
  98. alert("请正确输入!!");
  99. return false;
  100. }
  101. }
  102. </script>
  103. <%--<script>--%>
  104. <%-- function skimDetail(taskAccount){--%>
  105. <%-- //查看学生任务完成情况--%>
  106. <%-- window.location.href = "tea.action?action=goSkimDetail&taskAccount="+taskAccount;--%>
  107. <%-- }--%>
  108. <%--</script>--%>
  109. <%--<script>--%>
  110. <%-- function deleteThis(userAccount){--%>
  111. <%-- alert(userAccount);--%>
  112. <%-- }--%>
  113. <%-- function upThis(userAccount){--%>
  114. <%-- alert(userAccount);--%>
  115. <%-- }--%>
  116. <%--</script>--%>
  117. </html>
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <html>
  3. <head>
  4. <title>Title</title>
  5. <style>
  6. table{
  7. width: 1200px;
  8. }
  9. tr,td{
  10. border: grey 1px ;
  11. }
  12. td{
  13. height: 40px;
  14. }
  15. table td{
  16. height: 60px;
  17. vertical-align: middle!important; /*设置文字垂直居中*/
  18. text-align: center;
  19. }
  20. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  21. th{font-weight:bold;background:#ccc;}
  22. .con-b .row .lf{
  23. width: 15%;
  24. text-align: center;
  25. padding: 10px;
  26. }
  27. .con-b .row .rg{
  28. width: 85%;
  29. }
  30. .con-b tr:nth-of-type(odd){
  31. background-color: #f2f2f2;
  32. }
  33. #ee{
  34. width: 73px;
  35. height: 44px;
  36. }
  37. </style>
  38. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  39. </head>
  40. <body>
  41. <table border="1" cellspacing="0" align="center" class="con-b">
  42. <thead>
  43. <tr class="row" style="color: black;font-size: 25px" >
  44. <td class="lf">账户</td>
  45. <td class="lf">姓名</td>
  46. <td class="lf">性别</td>
  47. <td class="lf">生日</td>
  48. <td class="lf">身份证号码</td>
  49. <td class="lf">角色</td>
  50. <td class="lf">其他名称</td>
  51. <td class="lf">提交</td>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr>
  56. <c:forEach items="${arr}" var="person">
  57. <td class="lf">${person.getUserAccount()}</td>
  58. <td class="lf">
  59. <form action="common.action?action=upPersonName&userAccount=${person.getUserAccount()}" method="post">
  60. <input placeholder="${person.getUserName()}" type="text" name="userName" class="lf">
  61. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisName()" value="提交">
  62. </form>
  63. <td class="lf">
  64. <form action="common.action?action=upPersonSex&userAccount=${person.getUserAccount()}" method="post">
  65. <input placeholder="${person.getUserSex()}" type="text" name="userSex" class="lf">
  66. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisSex()" value="提交">
  67. </form>
  68. </td>
  69. <td class="lf">
  70. <form action="common.action?action=upPersonBirthday&userAccount=${person.getUserAccount()}" method="post">
  71. <input placeholder="${person.getUserBirthday()}" type="text" name="userBirthday" class="lf">
  72. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisBirthday(${person.getUserIdentify()})" value="提交">
  73. </form>
  74. </td>
  75. <td class="lf">${person.getUserIdCard()}</td>
  76. <td class="lf">
  77. <c:if test="${person.getUserIdentify()==1}">学生</c:if>
  78. <c:if test="${person.getUserIdentify()==0}">老师</c:if>
  79. </td>
  80. <td class="lf">
  81. <form action="common.action?action=upPersonOtherName&userAccount=${person.getUserAccount()}" method="post">
  82. <input placeholder="${person.getUserOtherName()}" type="text" name="OtherName" class="lf">
  83. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisOtherName(${person.getUserIdentify()})" value="提交">
  84. </form>
  85. </td>
  86. <td ><img style="width: 73px;height: 44px" src="tijiao.png" onclick="upThis(${person.getUserIdentify()})"> </td>
  87. </tr>
  88. </c:forEach>
  89. <span style="color:red; font-size: 5px" id="tip" ></span>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <script>
  94. function upThis(Identify){
  95. window.location.href="common.action?action=list";
  96. }
  97. function upThisName(){
  98. let userName = document.getElementById("userName").value;
  99. if (userName == null || userName.trim()==""){
  100. alert("请正确输入后提交");
  101. return false;
  102. }
  103. // if (Identify == 0){
  104. // window.location.href="tea.action?action=upSelfName";
  105. // }
  106. // if (Identify == 1){
  107. // window.location.href="common.action?action=upSelfName";
  108. // }
  109. // if (Identify ==2){
  110. // window.location.href="man.action?action=upSelfName";
  111. // }
  112. }
  113. function upThisSex(){
  114. let userSex = document.getElementById("userSex").value;
  115. if (userSex == null || userSex.trim()==""){
  116. alert("请正确输入后提交");
  117. return false;
  118. }
  119. // if (Identify == 0){
  120. // window.location.href="tea.action?action=upSelfSex";
  121. // }
  122. // if (Identify == 1){
  123. // window.location.href="common.action?action=upSelfSex";
  124. // }
  125. // if (Identify ==2){
  126. // window.location.href="man.action?action=upSelfSex";
  127. // }
  128. }
  129. function upThisBirthday(){
  130. let userBirthday = document.getElementById("userBirthday").value;
  131. if (userBirthday == null || userBirthday.trim()==""){
  132. alert("请正确输入后提交");
  133. return false;
  134. }
  135. // if (Identify == 0){
  136. // window.location.href="tea.action?action=upSelfBirthday";
  137. // }
  138. // if (Identify == 1){
  139. // window.location.href="common.action?action=upSelfBirthday";
  140. // }
  141. // if (Identify ==2){
  142. // window.location.href="man.action?action=upSelfBirthday";
  143. // }
  144. }
  145. function upThisOtherName(){
  146. let userOtherName = document.getElementById("userOtherName").value;
  147. if (userOtherName == null || userOtherName.trim()==""){
  148. alert("请正确输入后提交");
  149. return false;
  150. }
  151. // if (Identify == 0){
  152. // window.location.href="tea.action?action=upSelfOtherName";
  153. // }
  154. // if (Identify == 1){
  155. // window.location.href="common.action?action=upSelfOtherName";
  156. // }
  157. // if (Identify ==2){
  158. // window.location.href="man.action?action=upSelfOtherName";
  159. // }
  160. }
  161. </script>
  162. </body>
  163. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/23
  5. Time: 17:14
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>Title</title>
  12. <style>
  13. table{
  14. width: 1200px;
  15. }
  16. tr,td{
  17. border: grey 1px ;
  18. }
  19. td{
  20. height: 40px;
  21. }
  22. table td{
  23. height: 60px;
  24. vertical-align: middle!important; /*设置文字垂直居中*/
  25. text-align: center;
  26. }
  27. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  28. th{font-weight:bold;background:#ccc;}
  29. .con-b .row .lf{
  30. width: 15%;
  31. text-align: center;
  32. padding: 10px;
  33. }
  34. .con-b .row .rg{
  35. width: 85%;
  36. }
  37. .con-b tr:nth-of-type(odd){
  38. background-color: #f2f2f2;
  39. }
  40. #ee{
  41. width: 73px;
  42. height: 44px;
  43. }
  44. </style>
  45. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  46. </head>
  47. <body>
  48. <table border="1" cellspacing="0" align="center" class="con-b">
  49. <thead>
  50. <tr class="row" style="color: black;font-size: 25px" >
  51. <td class="lf">任务</td>
  52. <td class="lf">学生账户</td>
  53. <td class="lf">学生姓名</td>
  54. <td class="lf">学生答案</td>
  55. <td class="lf">是否完成</td>
  56. <td class="lf">分数</td>
  57. <td class="lf">修改分数</td>
  58. <td>删除</td>
  59. <%-- <td>查看评论</td>--%>
  60. <%-- <td>删除</td>--%>
  61. <%-- <td>修改</td>--%>
  62. </tr>
  63. </thead>
  64. <tbody>
  65. <tr>
  66. <c:forEach items="${arr}" var="taskDetail">
  67. <td class="lf">${taskDetail.getTaskAccount()}</td>
  68. <td class="lf">${taskDetail.getStudentAccount()}</td>
  69. <td class="lf">${taskDetail.getStudentName()}</td>
  70. <td class="lf">${taskDetail.getStudentAnswer()}</td>
  71. <td class="lf">
  72. <c:if test="${taskDetail.getIsFinish()==0}"><span style="color: red">未完成</span></c:if>
  73. <c:if test="${taskDetail.getIsFinish()==1}"><span style="color: aqua">已完成</span></c:if>
  74. </td>
  75. <%-- <td class="lf">${taskDetail.getScore()}</td>--%>
  76. <td class="lf">
  77. <form action="tea.action?action=upScoree&taskAccount=${taskDetail.getTaskAccount()}" method="post">
  78. <input placeholder="${taskDetail.getScore()}" type="text" id="Score" name="Score" class="lf">
  79. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upScoree()" value="提交">
  80. <span style="color:red; font-size: 5px" id="tip" ></span>
  81. </form>
  82. </td>
  83. <td class="lf"><img style="width: 83px;height: 44px" src="xiugai.png" onclick="upScore(${taskDetail.getStudentAccount()})"> </td>
  84. <td><img style="width: 83px;height: 44px" src="shanchu.png"
  85. onclick="delete(${taskDetail.getTaskAccount()})"></td>
  86. <%-- <td class="lf">${person.getUserIdCard()}</td>--%>
  87. <%-- <td class="lf">--%>
  88. <%-- <c:if test="${person.getUserIdentify()==0}">学生</c:if>--%>
  89. <%-- <c:if test="${person.getUserIdentify()==1}">老师</c:if>--%>
  90. <%-- </td>--%>
  91. <%-- <td class="lf">${person.getUserOtherName()}</td>--%>
  92. <%-- <td ><img style="width: 73px;height: 44px" onclick="deleteThis('${person.getUserAccount()}')" src="shanchu.png"> </td>--%>
  93. <%-- <td ><img style="width: 73px;height: 44px" src="xiugai.png" onclick="upThis('${person.getUserAccount()}')"> </td>--%>
  94. </tr>
  95. </c:forEach>
  96. </tr>
  97. </tbody>
  98. </table>
  99. </body>
  100. <script>
  101. function upScoree(){
  102. let Score = document.getElementById("Score").value;
  103. if (Score == null || Score.trim()==""){
  104. // alert("账户不能为空");
  105. document.getElementById("tip").innerHTML = "请输入分数";
  106. return false;
  107. }
  108. }
  109. </script>
  110. <%--<script>--%>
  111. <%-- function skimDetail(taskAccount){--%>
  112. <%-- //查看学生任务完成情况--%>
  113. <%-- window.location.href = "tea.action?action=goSkimDetail&taskAccount="+taskAccount;--%>
  114. <%-- }--%>
  115. <%--</script>--%>
  116. <%--<script>--%>
  117. <%-- function deleteThis(userAccount){--%>
  118. <%-- alert(userAccount);--%>
  119. <%-- }--%>
  120. <%-- function upThis(userAccount){--%>
  121. <%-- alert(userAccount);--%>
  122. <%-- }--%>
  123. <%--</script>--%>
  124. </html>
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <html>
  3. <head>
  4. <title>Title</title>
  5. <style>
  6. table{
  7. width: 1200px;
  8. }
  9. tr,td{
  10. border: grey 1px ;
  11. }
  12. td{
  13. height: 40px;
  14. }
  15. table td{
  16. height: 60px;
  17. vertical-align: middle!important; /*设置文字垂直居中*/
  18. text-align: center;
  19. }
  20. tr,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
  21. th{font-weight:bold;background:#ccc;}
  22. .con-b .row .lf{
  23. width: 15%;
  24. text-align: center;
  25. padding: 10px;
  26. }
  27. .con-b .row .rg{
  28. width: 85%;
  29. }
  30. .con-b tr:nth-of-type(odd){
  31. background-color: #f2f2f2;
  32. }
  33. #ee{
  34. width: 73px;
  35. height: 44px;
  36. }
  37. </style>
  38. <%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
  39. </head>
  40. <body>
  41. <table border="1" cellspacing="0" align="center" class="con-b">
  42. <thead>
  43. <tr class="row" style="color: black;font-size: 25px" >
  44. <td class="lf">账户</td>
  45. <td class="lf">姓名</td>
  46. <td class="lf">性别</td>
  47. <td class="lf">生日</td>
  48. <td class="lf">身份证号码</td>
  49. <td class="lf">角色</td>
  50. <td class="lf">其他名称</td>
  51. <td class="lf">提交</td>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr>
  56. <c:forEach items="${arr}" var="person">
  57. <td class="lf">${person.getUserAccount()}</td>
  58. <td class="lf">
  59. <c:if test="${person.getUserIdentify()==0}"> <form action="tea.action?action=upSelfName&userAccount=${person.getUserAccount()}" method="post">
  60. <input placeholder="${person.getUserName()}" type="text" name="userName" class="lf">
  61. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisName()" value="提交">
  62. </form></c:if>
  63. <c:if test="${person.getUserIdentify()==1}"> <form action="common.action?action=upSelfName&userAccount=${person.getUserAccount()}" method="post">
  64. <input placeholder="${person.getUserName()}" type="text" name="userName" class="lf">
  65. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisName()" value="提交">
  66. </form></c:if>
  67. <c:if test="${person.getUserIdentify()==2}"> <form action="man.action?action=upSelfName&userAccount=${person.getUserAccount()}" method="post">
  68. <input placeholder="${person.getUserName()}" type="text" name="userName" class="lf">
  69. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisName(${person.getUserIdentify()})" value="提交">
  70. </form></c:if></td>
  71. <td class="lf">
  72. <c:if test="${person.getUserIdentify()==0}"><form action="tea.action?action=upSelfSex&userAccount=${person.getUserAccount()}" method="post">
  73. <input placeholder="${person.getUserSex()}" type="text" name="userSex" class="lf">
  74. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisSex()" value="提交">
  75. </form></c:if>
  76. <c:if test="${person.getUserIdentify()==1}"><form action="common.action?action=upSelfSex&userAccount=${person.getUserAccount()}" method="post">
  77. <input placeholder="${person.getUserSex()}" type="text" name="userSex" class="lf">
  78. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisSex()" value="提交">
  79. </form></c:if>
  80. <c:if test="${person.getUserIdentify()==2}"><form action="man.action?action=upSelfSex&userAccount=${person.getUserAccount()}" method="post">
  81. <input placeholder="${person.getUserSex()}" type="text" name="userSex" class="lf">
  82. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisSex()" value="提交">
  83. </form></c:if>
  84. </td>
  85. <td class="lf">
  86. <c:if test="${person.getUserIdentify()==0}"> <form action="tea.action?action=upSelfBirthday&userAccount=${person.getUserAccount()}" method="post">
  87. <input placeholder="${person.getUserBirthday()}" type="text" name="userBirthday" class="lf">
  88. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisBirthday(${person.getUserIdentify()})" value="提交">
  89. </form></c:if>
  90. <c:if test="${person.getUserIdentify()==1}"> <form action="common.action?action=upSelfBirthday&userAccount=${person.getUserAccount()}">
  91. <input placeholder="${person.getUserBirthday()}" type="text" name="userBirthday" class="lf">
  92. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisBirthday(${person.getUserIdentify()})" value="提交">
  93. </form></c:if>
  94. <c:if test="${person.getUserIdentify()==2}"> <form action="man.action?action=upSelfBirthday&userAccount=${person.getUserAccount()}">
  95. <input placeholder="${person.getUserBirthday()}" type="text" name="userBirthday" class="lf">
  96. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisBirthday(${person.getUserIdentify()})" value="提交">
  97. </form></c:if>
  98. </td>
  99. <td class="lf">${person.getUserIdCard()}</td>
  100. <td class="lf">
  101. <c:if test="${person.getUserIdentify()==1}">学生</c:if>
  102. <c:if test="${person.getUserIdentify()==0}">老师</c:if>
  103. </td>
  104. <td class="lf">
  105. <c:if test="${person.getUserIdentify()==0}"> <form action="tea.action?action=upSelfOtherName&userAccount=${person.getUserAccount()}" method="post">
  106. <input placeholder="${person.getUserOtherName()}" type="text" name="OtherName" class="lf">
  107. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisOtherName(${person.getUserIdentify()})" value="提交">
  108. </form></c:if>
  109. <c:if test="${person.getUserIdentify()==1}"> <form action="common.action?action=upSelfOtherName&userAccount=${person.getUserAccount()}" method="post">
  110. <input placeholder="${person.getUserOtherName()}" type="text" name="OtherName" class="lf">
  111. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisOtherName(${person.getUserIdentify()})" value="提交">
  112. </form></c:if>
  113. <c:if test="${person.getUserIdentify()==2}"> <form action="man.action?action=upSelfOtherName&userAccount=${person.getUserAccount()}" method="post">
  114. <input placeholder="${person.getUserOtherName()}" type="text" name="OtherName" class="lf">
  115. <input type="submit" style="width: 80px ;margin-left :40px;margin-left: 5px" onclick="return upThisOtherName(${person.getUserIdentify()})" value="提交">
  116. </form></c:if>
  117. </td>
  118. <td ><img style="width: 73px;height: 44px" src="tijiao.png" onclick="upThis(${person.getUserIdentify()})"> </td>
  119. </tr>
  120. </c:forEach>
  121. <span style="color:red; font-size: 5px" id="tip" ></span>
  122. </tr>
  123. </tbody>
  124. </table>
  125. <script>
  126. function upThis(Identify){
  127. if (Identify == 0){
  128. window.location.href="tea.action?action=myThing";
  129. }
  130. if (Identify == 1){
  131. window.location.href="common.action?action=myThing";
  132. }
  133. if (Identify ==2){
  134. window.location.href="man.action?action=myThing";
  135. }
  136. }
  137. function upThisName(){
  138. let userName = document.getElementById("userName").value;
  139. if (userName == null || userName.trim()==""){
  140. alert("请正确输入后提交");
  141. return false;
  142. }
  143. // if (Identify == 0){
  144. // window.location.href="tea.action?action=upSelfName";
  145. // }
  146. // if (Identify == 1){
  147. // window.location.href="common.action?action=upSelfName";
  148. // }
  149. // if (Identify ==2){
  150. // window.location.href="man.action?action=upSelfName";
  151. // }
  152. }
  153. function upThisSex(){
  154. let userSex = document.getElementById("userSex").value;
  155. if (userSex == null || userSex.trim()==""){
  156. alert("请正确输入后提交");
  157. return false;
  158. }
  159. // if (Identify == 0){
  160. // window.location.href="tea.action?action=upSelfSex";
  161. // }
  162. // if (Identify == 1){
  163. // window.location.href="common.action?action=upSelfSex";
  164. // }
  165. // if (Identify ==2){
  166. // window.location.href="man.action?action=upSelfSex";
  167. // }
  168. }
  169. function upThisBirthday(){
  170. let userBirthday = document.getElementById("userBirthday").value;
  171. if (userBirthday == null || userBirthday.trim()==""){
  172. alert("请正确输入后提交");
  173. return false;
  174. }
  175. // if (Identify == 0){
  176. // window.location.href="tea.action?action=upSelfBirthday";
  177. // }
  178. // if (Identify == 1){
  179. // window.location.href="common.action?action=upSelfBirthday";
  180. // }
  181. // if (Identify ==2){
  182. // window.location.href="man.action?action=upSelfBirthday";
  183. // }
  184. }
  185. function upThisOtherName(){
  186. let userOtherName = document.getElementById("userOtherName").value;
  187. if (userOtherName == null || userOtherName.trim()==""){
  188. alert("请正确输入后提交");
  189. return false;
  190. }
  191. // if (Identify == 0){
  192. // window.location.href="tea.action?action=upSelfOtherName";
  193. // }
  194. // if (Identify == 1){
  195. // window.location.href="common.action?action=upSelfOtherName";
  196. // }
  197. // if (Identify ==2){
  198. // window.location.href="man.action?action=upSelfOtherName";
  199. // }
  200. }
  201. </script>
  202. </body>
  203. </html>
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: 峰。
  4. Date: 2023/8/18
  5. Time: 13:47
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <html>
  10. <head>
  11. <title>登录界面</title>
  12. <style>
  13. #outerLoginFrame{
  14. width: 500px;
  15. height: 500px;
  16. margin-left: 500px;
  17. margin-top: 200px;
  18. border: white 0px solid;
  19. }
  20. #innerLoginFrame{
  21. width: 360px;
  22. /*border: grey 2px solid;*/
  23. margin-left: 80px;
  24. margin-top: 50px;
  25. height: 250px;
  26. color: grey;
  27. font-size: 25px;
  28. }
  29. input{
  30. width: 220px;
  31. height: 30px;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div id="outerLoginFrame" style="border:grey 2px solid">
  37. <%-- <span style="position: center"></span>--%>
  38. <h1 style="margin-top: 40px;margin-left: 120px;color: grey">教&nbsp务&nbsp管&nbsp理&nbsp系&nbsp统</h1>
  39. <div id="innerLoginFrame">
  40. <form action="UserLogin" method="post" >
  41. 账户:<input type="text" id="userAccount" name="userAccount" class="myText"><br><br>
  42. 密码:<input type="password" id="userPassword" name="userPassword" class="myText"><br><br>
  43. <input type="submit" style="width: 140px ;margin-left :40px" onclick="return checkLogin()" value="登录">
  44. <a href="register.jsp" type="submit" style="width: 140px ;margin-left :20px" value="注册">|&nbsp&nbsp注册</a><br>
  45. <span style="color:red; font-size: 5px" id="tip" ></span>
  46. </form>
  47. </div>
  48. </div>
  49. </body>
  50. </html>
  51. <script>
  52. <%-- 方法--%>
  53. function checkLogin(){
  54. // alert("进来") 弹窗
  55. let userAccount = document.getElementById("userAccount").value;
  56. let userPassword = document.getElementById("userPassword").value;
  57. if (userAccount == null || userAccount.trim()==""){
  58. // alert("账户不能为空");
  59. document.getElementById("tip").innerHTML = "账户不能为空";
  60. return false;
  61. }
  62. else if (userPassword == null || userPassword.trim()==""){
  63. // alert("密码不能为空");
  64. document.getElementById("tip").innerHTML = "密码不能为空";
  65. return false;
  66. }
  67. }
  68. </script>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/556279
推荐阅读
相关标签
  

闽ICP备14008679号